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 '=='.

回答(1 个)

Rik
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)
data = struct with fields:
meanBlink: 0.3400 ltime: 0.8662 detrend: 0.9240 w: 0.4217 f: 0.9188 coi: 0.9104 cycph: 0.6672
Blink_spectrum =struct(data=data)
Blink_spectrum = struct with fields:
data: [1×1 struct]
  3 个评论
Walter Roberson
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
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 CenterFile Exchange 中查找有关 Signal Generation and Preprocessing 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by