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

17 views (last 30 days)
Error evaluating 'InitFcn' callback of block_diagram 'DFIG_SMC'. Callback string is '% Parametrs for DFIG with SMC
% Parametrs for DFIG with SMC
f=50;
Ps=2e6;
n=1500;
Vs=690;
Is=1760;
Tem=12732;
Vr=2070;
p=2;
u=1/3;
smax=1/3;
Vr_stator=(Vr*smax)*u;
Rs=2.6e-3;
Ls=2.587e-3;
Rr'=26.1e-3;
Lr'=2.587e-3;
Lm=2.51e-3;
Rm=1.0805e6;
Vbus=Vr_stator*sqrt(2);
sigma=(1-Lm^2)/(Ls*Lr);
Vs=690*sqrt(2/3);
ws=f*2*pi;
J=127/2;
D=1e-3;
fsw=4e3;
Ts=1/fsw/50;
F=0.058;
%% Maximum and Minimum wind speeds
wt_nom=18;
wt_min=9;
%% Three Blade wind turbine model
N=100;
Radio=42;
ro=1.225;
%% Cp and Ct curves
beta=0;
ind2=1;
%% Kopt for MPPT
Cp_max=0.44;
lambda_opt=7.2;
Kopt=((0.5*rho*pi(Radio^5)*Cp_max)/(lambda_opt^3));
%% Torque and speed inputs
Temm=Torque/N;
wmm=wt*(50/2/pi)*N;
sss=(1500-wmm)/1500;
%% Grid side converter
Cbus=80e-3;
Cg=20e-6;
Lg=400e-6;
Kpg=1/(1.5*Vs*sqrt(2/3));
Kqg=-Kpg;
%% Mechanical Inputs
Theta=20;
Speed=1500;
Caused by:
  • Error: Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.
  5 Comments
John D'Errico
John D'Errico on 21 Jul 2020
Edited: John D'Errico on 21 Jul 2020
What can I say? You need to learn to use MATLAB. You need to write your code a bit more carefully.
And when you get an error, read the ENTIRE error message. If you ask a question on answers, report the ENTIRE ERROR MESSAGE. Thus EVERYTHING IN RED.
Here, for example, you got the error message:
Error using pi
Too many input arguments.
That should give you the hint that maybe you are using pi improperly. So now, look at your code. READ THE CODE YOU WROTE! I see this line:
ws=f*2*pi;
There, pi clearly has no arguments. So look further.
Kopt=((0.5*rho*pi(Radio^5)*Cp_max)/(lambda_opt^3));
We see pi here. Now, you need to understand that MATLAB does not allow implicit multiplication. It does not understand that when you write the expression
pi(radio^5)
that your intention is to write the PRODUCT of pi and the value radio^5.
MATLAB cannot read your mind to infer that. Instead, it ssumes that pi is a function or a vector or array. What is pi?
exist('pi')
ans =
5
In turn, this tells us that pi is an existing MATLAB function. In fact, pi is a function that accepts NO input arguments.
Now, what did you do? You effectively tried to execute the FUNCTION pi, passing in the argument radio^5. That is how MATLAB sees it. So you effectively called the function pi with an input argument.
Error using pi
Too many input arguments.
Yes, you just forgot to put in a * there to denote multiplication. MATLAB assumes you know what you are doing, at least until it becomes clear that MATLAB has no idea what you are telling it to do. Then it throws out an error.
The error message told you what you needed to know. You had to read the ENTIRE error message, and think about what the message told you.
Azariah Seblu
Azariah Seblu on 19 Jul 2021
Thank you @John D'Errico for the excellent, detailed response. You are very good with MATLAB! Hope to see you around the forum in the future!

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 20 Jul 2020
Rr'=26.1e-3;
Apostrophe cannot be part of a variable name in MATLAB Function Block or Callbacks.

More Answers (1)

John D'Errico
John D'Errico on 20 Jul 2020
A simple rule in MATLAB: You cannot assign a result to a result.
What is Rr' then? This is the conjugate transpose of the array or vector Rr. MATLAB does not truly care that Rr is apparently a scalar.
Rr'=26.1e-3;
Lr'=2.587e-3;
My guess is you wanted to name a variable like that. Sorry, but Rr' is not a valid variable name. So, what error arises? MATLAB thinks the left hand side is the conjugate transpose of something called Rr, that is, it sees the result of an operation. Therefore, it thinks you may want to compare the two results for equality, thus the error message.

Categories

Find more on Wind Power 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!