dtu-dsp / Robochameleon

A matlab coding framework and component library for simulation and experimental analysis of optical communication systems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in 'unit.m' when parsing properties that are not used by the class.

bebopsan opened this issue · comments

If I parse properties that are not used by the class I get the following error:

Error using strjoin (line 53)
First input must be a 1xN cell array of strings. 
Error in unit/setparams (line 345)
            if any(ai2), robolog('Following properties: %s are not used by the class.', 'NFO0',
            strjoin(strcat('''',f(ai2),''''),', ')); end

When I should have had only the warning:

'Following properties: %s are not used by the class.', 'NFO0', strjoin(strcat('''',f(ai2),''''),'

I think this is because 'f' is a Nx1 array instead of a 1xN array.
I temporarily solved the issue by transposing the argument:

if any(ai2), robolog('Following properties: %s are not used by the class.', 'NFO0', strjoin(strcat('''',f(ai2),'''')',', ')); end

I know parsing properties that are not used by the class is not very smart, but nevertheless the warning should not give an error.

Kind regards,
/Santiago

Hej,
I cannot reproduce your problem. Pull the latest commit and run the following:

param.noProperty = 1337;
NonlinearChannel_v1(param)

This runs for me. Can you provide us with code such that we can reproduce the error?
Thanks

Hello,
I have been able to reproduce the error by doing the following on the latest commit:

param.noProperty = 1337;
param.otherNoProperty = 1337;
param.nSpans = 2;
NonlinearChannel_v1(param)

This gives a mix of default and no properties such that ai2 has ones and zeros. Again by transposing the strjoin( ) I can overcome the error.

What version of MATLAB are you using? I cannot reproduce the error.

Good question,

I just noticed its failing in version 2013b (a pc in the lab) and works in another computer that runs version 2016b.

In the 2016b version strjoin({'a','b','c'},', ') gives the same output as strjoin({'a';'b';'c'},', ')

but in the 2013b version, the second gives an error:

 strjoin({'a';'b';'c'},', ')
Error using strjoin (line 53)
First input must be a 1xN cell array of strings.