Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.
3 views (last 30 days)
Show older comments
Hello and sorry for the insertion of my code it's my first time using this website. I'm trying to create a structure in order to define my blink spectrum into a variable as to use next in my autoregressive model (ar). But when i try to run the "%% Blink, AR spectrum" section i'm having this error "Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='."
Thanks you for you answers
%% blink, type Spectrum
ltime = time.*ms_to_sec;
[w f] = wt([ltime' detrend(meanBlink)]);
f = 1./f * 3600;
coi = 1./f * 3600;
cycph = 20;
w = mean(abs(w(f<cycph, :)).^2, 2);
%% Blink, AR spectrum
Blink_spectrum = struct(...
"data.meanBlink" = meanBlink;
"data.ltime" = ltime';
"data.detrend" = detrend;
"data.w" = w;
"data.f" = f;
"data.coi" = coi;
"data.cycph" = cycph);
ar(Blink_spectrum,2)
Error: File: figure3.m Line: 464 Column: 22
Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.
0 Comments
Answers (1)
Rik
on 4 Jul 2022
If you want to use the Name=Value syntax, you need to do this:
meanBlink=rand;ltime=rand;detrend=rand;w=rand;f=rand;coi=rand;cycph=rand;
data=struct(...
meanBlink = meanBlink, ...
ltime = ltime', ...
detrend = detrend, ...
w = w, ...
f = f, ...
coi = coi, ...
cycph = cycph)
Blink_spectrum =struct(data=data)
3 Comments
Walter Roberson
on 27 Feb 2023
When you use = between an option name (or field name) and the associated value, then you do not put the option name inside '' or inside "" .
Also field names for struct() as a call must be plain variable names, with no . in them.
Rik
on 27 Feb 2023
Internally Matlab will put double quotes around the first part, so these two syntaxes look the same to the function being called:
SomeFunction(meanBlink = 1)
SomeFunction("meanBlink",1)
See Also
Categories
Find more on Signal Generation and Preprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!