Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Rik
2022-7-4
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 个评论
Walter Roberson
2023-2-27
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
2023-2-27
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)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Signal Generation and Preprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!