Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.
Show older comments
Asking for help.
ERROR "Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='."
I already followed instruction above but another happened
ERROR 2: Illegal use of reserved keyword "for".
This is my code.
clc;
clear;
%dx/dt=ax-bxy Predator
%dy/dt=-cy+dxy prey
%constants as stated on the problem
a = 1.2;
b = 0.6;
c = 0.8;
d = 0.3;
%Defining the functions
%z[x,y]<=z(1,:)= y z(2,:)=x
f=@(t,z)[ ...
+a*z(2)-b*z(2)*z(1)
-c*z(1)+d*z(2)*z(1)
fx==@(t,x,y) a*x - b*x*y;
fy==@(t,x,y) -c*y + d*x*y;
%Initial Conditions
t(1)=0; %time
% x(1)=2; %predator
% y(1)=1; %prey
z(:,1)=[1,2];
%step size
h = 0.001;
tfinal = 30;
N = 1000;
%Loop
for i=1:N
Update time
t(i+1)=t(i)+h;
%update for z
k1=f(t(i), z(:,i));
k2=f(t(i)+h/2, z(:,i)+h/2*k1);
k3=f(t(i)+h/2, z(:,i)+h/2*k2);
k4=f(t(i)+h, z(:,i)+h *k3);
z(:,i+1)=y(:,i) +h/6*(k1+ 2*k2 +2*k3 +k4);
end
%plotting
figure(1)
clf(1)
plot(t,y(1,:))
hold on
plot(t,y(2,:))
xlabel('Time')
ylabel('Populations')
hold off
Thank you and have a nice day
Accepted Answer
More Answers (2)
Tareq Rahmani
on 23 Mar 2020
0 votes
what is wrong here :

1 Comment
Stephen23
on 23 Mar 2020
@Tareq Rahmani: in MATLAB square brackets are a concatenation operator. What are you concatenating?
Simbarashe Zuva
on 24 Dec 2021
Edited: Walter Roberson
on 24 Dec 2021
I also have the same problem with my code
The problem on line 40
I do i go about this error? I'm really new to matlab
% Dhtr and Dhte, for HOG of the input samples
u = ones(1,1600);
ytr = [u 2*u 3*u 4*u 5*u 6*u 7*u 8*u 9*u 10*u];
H = [];
for i = 1:1600
xi = X1600(:,i);
mi = reshape(xi,28,28);
hi = hog20(mi,7,9);
H = [H hi];
end
Dhtr = [H; ytr];
Hte = [];
for i = 1:length(Lte28)
xi = Te28(:,i);
mi = reshape(xi,28,28);
hi = hog20(mi,7,9);
Hte = [Hte hi];
end
Dhte = [Hte; 1+Lte28(:)'];
% MATLAB code for constructing Dtr and Dte for the original training and test
data sets
u = ones(1,1600);
ytr = [u 2*u 3*u 4*u 5*u 6*u 7*u 8*u 9*u 10*u];
Dtr = [X1600; ytr];
Dte = [Te28; 1+Lte28(:)'];
[ori_ws,ori_f]= SRMCC_bfgsoriML(Dtr,'f_SRMCC','g_SRMCC',0.002,10,62);
Dte(785,:) = ones(1,10000);
[~,ori_ind_pre] = max((Dte'*ori_ws)');
K = 10;
ytest = 1+Lte28(:)';
ori_C = zeros(K,K);
for j = 1:K
ind_j = find(ytest==j);
for i = 1:K
ind-pre_i = find(ori_ind_pre == i);
ori_C(i,j) = length(intersect(ind_j,ind_pre_i));
end
end
[hog_ws,hog_f]= SRMCC_bfgsML(Dtr,'f_SRMCC','g_SRMCC',0.001,10,57);
Dte(785,:) = ones(1,10000);
[~,hog_ind_pre] = max((Dte'*hog_ws)');
K = 10;
ytest = 1+Lte28(:)';
hog_C = zeros(K,K);
for j = 1:K
ind_j = find(ytest==j);
for i = 1:K
ind-pre_i = find(hog_ind_pre == i);
hog_C(i,j) = length(intersect(ind_j,ind_pre_i));
end
end
6 Comments
Simbarashe Zuva
on 24 Dec 2021
The datasets in question are MNIST for training and test
Walter Roberson
on 24 Dec 2021
Your line has
ind-pre_i = find(ori_ind_pre == i);
But should have
ind_pre_i = find(ori_ind_pre == i);
You tried to use a hyphen as part of a variable name.
Dam
on 8 Dec 2022
I have the same error with the following code. Please I need help!
rayChan = comm.RayleighChannel( ...
SampleRate=100000, ...
MaximumDopplerShift=130,...
PathDelays=[0 1.5e-5 3.2e-5], ...
AveragePathGains=[0, -3, -3], ...
Visualization='Impulse response');
SampleRate=100000, ...
↑
Error: Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use
'=='.
Dam
on 8 Dec 2022
Same error with the following code:
ricChan = comm.RicianChannel( ...
SampleRate=sampleRate500kHz, ...
PathDelays=delayVector, ...
AveragePathGains=gainVector, ...
KFactor=KFactor, ...
DirectPathDopplerShift=specDopplerShift, ...
MaximumDopplerShift=maxDopplerShift, ...
RandomStream="mt19937ar with seed", ...
Seed=100, ...
PathGainsOutputPort=true);
SampleRate=sampleRate500kHz, ...
↑
Error: Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use
'=='.
Walter Roberson
on 8 Dec 2022
That code is written for a newer version of MATLAB than you are using. Convert each place that has NAME=VALUE to 'NAME', VALUE
For example Seed=100 would be 'Seed', 100
Dam
on 9 Dec 2022
Thanks a million Walter Roberson. It works. I'm now inspired to learn matlab
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!