Cannot execute Figure(3).

1 次查看(过去 30 天)
N/A
N/A 2022-9-29
Hello,
Was doing my assignments and have managed to solve all except last one, where, I couldn't execute Figure(3) to plot the graph in mathlab.
Here's my code so far. (please see Figure(3) code if there's anything wrong)
k=0.000124; %mass transfer coefficient
d=0.00057; %diameter of the membrane tube
Q=3.4*10.^-8; %flow rate of water
z=linspace(0,0.5); %distance along the length of membrane tube
y=1-exp(-(((k*pi*d)/Q))*z); %Given Equation. Let y be (C/Cr)
figure(1); %Question 3a
plot(z,y);
xlabel('Distance')
ylabel('Concentration')
grid on;
%----------------------------%
%To study the effect of diameter of membrane%
D=[0.0004275;0.00057;0.0007125]; %Calculate manually on 0.75d, d, 1.25d;
Y=1-exp(-(((k*pi*D)/Q))*z); %Given Equation. Let Y be C/Cr to study the diameter of the membrane
figure(2); %effect of diameter of the membrane
plot(z,Y);
xlabel('Distance')
ylabel('Concentration')
legend('0.75d','d','1.25d')
grid on;
%------------------------------------%
%Effect on flow rate%
q=[0.000000025;0.000000034;0.000000042]; %Calculate manually on 0.75Q, Q, 1.25Q;
f=1-exp(-(((k*pi*d)/q))*z);
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To operate on each element of the matrix
individually, use TIMES (.*) for elementwise multiplication.
figure(3); %effect of flow rate
plot(z,f);
xlabel('Distance')
ylabel('Concentration')
legend('0.75Q','Q','1.25Q')
grid on;
Thank you and appreciate your help! :)
  1 个评论
Rik
Rik 2022-9-29
Did you try following the advice in the error message?

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2022-9-29
q=[0.000000025;0.000000034;0.000000042]; %Calculate manually on 0.75Q, Q, 1.25Q;
f=1-exp(-(((k*pi*d)/q))*z);
The / operator is not division and the * operator is not multiplication. The * and / operators are matrix operations, inner product for * and matrix division for /
You need to use .* and ./ instead

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by