Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.

3 Ansichten (letzte 30 Tage)
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 '=='.

Antworten (1)

Rik
Rik am 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)
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 Kommentare
Walter Roberson
Walter Roberson am 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
Rik am 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)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Signal Integrity Kits for Industry Standards finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by