Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
asd ad
am 14 Aug. 2020
Kommentiert: Steven Lord
am 5 Okt. 2022
Hello everyone,
I'm getting the aformentioned error for the RL2 variable but I do not want to compare values for equality. I just want to put RL2 = RL/2. This problem persists even when I remove that line of code. The same problem occurs for H matrix when I remove the line of code for RL2 and the same occurs for R when I remove the line of code for H matrix. Why is this happening?
Thanks
clear all
close all
clc
R1 = 0; R2 = 100; R3 = 125; R4 = 150; R5 = 200; R6 = 250; R7 = 500; R8 = 1000;
R9 = 2000;
L1 = 0; L2 = 2.5; L3 = 5; L4 = 7.5; L5 = 10; L6 = 12.5; L7 = 15; L8 = 17.5; L9 = 20;
RL = [R1*L1 R2*L1 R3*L1 R4*L1 R5*L1 R6*L1 R7*L1 R8*L1 R9*L1;
R1*L2 R2*L2 R3*L2 R4*L2 R5*L2 R6*L2 R7*L2 R8*L2 R9*L2;
R1*L3 R2*L3 R3*L3 R4*L3 R5*L3 R6*L3 R7*L3 R8*L3 R9*L3;
R1*L4 R2*L4 R3*L4 R4*L4 R5*L4 R6*L4 R7*L4 R8*L4 R9*L4;
R1*L5 R2*L5 R3*L5 R4*L5 R5*L5 R6*L5 R7*L5 R8*L5 R9*L5;
R1*L6 R2*L6 R3*L6 R4*L6 R5*L6 R6*L6 R7*L6 R8*L6 R9*L6;
R1*L7 R2*L7 R3*L7 R4*L7 R5*L7 R6*L7 R7*L7 R8*L7 R9*L7;
R1*L8 R2*L8 R3*L8 R4*L8 R5*L8 R6*L8 R7*L8 R8*L8 R9*L8;
R1*L9 R2*L9 R3*L9 R4*L9 R5*L9 R6*L9 R7*L9 R8*L9 R9*L9;
RL2 = (RL/2);
H = [73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00;
70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17;
67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34;
64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19;
61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36;
58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53;
55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38;
49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72;
43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74;
37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76;
32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09;
23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60;
15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73;
7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87;
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00];
R = [R1 R2 R3 R4 R5 R6 R7 R8 R9;
R1 R2 R3 R4 R5 R6 R7 R8 R9;
R1 R2 R3 R4 R5 R6 R7 R8 R9;
R1 R2 R3 R4 R5 R6 R7 R8 R9;
R1 R2 R3 R4 R5 R6 R7 R8 R9;
R1 R2 R3 R4 R5 R6 R7 R8 R9;
R1 R2 R3 R4 R5 R6 R7 R8 R9;
R1 R2 R3 R4 R5 R6 R7 R8 R9;
R1 R2 R3 R4 R5 R6 R7 R8 R9;
R1 R2 R3 R4 R5 R6 R7 R8 R9;
R1 R2 R3 R4 R5 R6 R7 R8 R9;
R1 R2 R3 R4 R5 R6 R7 R8 R9;
R1 R2 R3 R4 R5 R6 R7 R8 R9;
R1 R2 R3 R4 R5 R6 R7 R8 R9;
R1 R2 R3 R4 R5 R6 R7 R8 R9];
contourf(RL2,R,H)
k = colorbar;
cmap = colormap;
ax = gca;
ax.Color = cmap(1, :);
k.Label.String = 'Relative Humidity (%)';
xlabel('Length (\mum)')
ylabel('Radius (\mum)')
2 Kommentare
Ruslan Smirnov
am 5 Okt. 2022
Bearbeitet: Ruslan Smirnov
am 5 Okt. 2022
surprisingly, when trying to execute code section by section, problems with incomplete lines or wrong usage of = operator affect the execution of previous lines; pathetic
Steven Lord
am 5 Okt. 2022
@asd ad Rather than defining individual variables named R1 through R9 and L1 through L9, I recommend defining a vector.
R = 1:9;
L = 10:19;
With vectors and implicit expansion, you can assemble those matrices with a lot less typing.
A = R.*(L.')
As a check, A(3,4) should be R(4)*L(3).
[A(3,4) R(4)*L(3)]
Akzeptierte Antwort
Walter Roberson
am 14 Aug. 2020
RL2 = (RL/2;
That is an incomplete expression that would cause problems for what follows.
4 Kommentare
Walter Roberson
am 14 Aug. 2020
After you put in the ] for RL then there are no more syntax errors, but you have the problem that in your call
contourf(RL2,R,H)
then RL2 is 9 x 9 but R and H are 15 x 9
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!