Can someone please help! I cannot plot this graph. Multiple 3 line graph.
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi guys, i've tried to plot graph after calculation for 5x3. Unfortunately the graph plotted for last row. When recheck graph data found for 1st and 2nd row shows as 0. But on the output table has all the data.
Please help me fix it.
Only have an error as "add preallocation for speed".
here is the calulated table(Terget is for maximum Pressure)

Here is my graph

>>supposed have to show 3 staright line graph
Table for the graph...collumn 1 and 2 has no data.

here is my code. please help.
clear;
clc;
r = 0.05; %radius in meter
viscosity = [256E-3, 544E-3, 1200E-3, 3680E-3, 5440E-3]; %viscosity in pa.s
l = 0.08; %length in meter
rm = 0.075; %mean radius
N = [1000,3000,4000]; %speed in rpm
sh = 10E-6; %sh in unit meter
fprintf(' ---------------------------------------------------------------------------------------\n');
fprintf(' |Speed (RPM)\tVelocity (m/s)\t\tViscosity (Pa.s)\tMaximum Pressure(MPa) | \n ');
fprintf('---------------------------------------------------------------------------------------\n');
for i = 1:length(N)
u = ((2.*3.142.*N(i))./60)*rm;
for j = 1:length(viscosity)
ho = sh/1.4142;
pm = ((3*u*viscosity(j)*l*sh)/((2*ho)*(sh+ho)*(sh+(2*ho))))/10^6;
fprintf(' | %d\t\t\t%0.6d\t\t\t%0.6d\t\t\t%0.6d\t |\n', N(i), u, viscosity(j), pm);
end
fprintf(' ---------------------------------------------------------------------------------------\n');
end
figure;for i = 1:length(N)
end
u = ((2.*3.142.*N(i))./60)*rm;
for j = 1:length(viscosity)
ho = sh/1.4142;
pm = ((3*u*viscosity(j)*l*sh)/((2*ho)*(sh+ho)*(sh+(2*ho))))/10^6;
viscosity_pm(j,i) = pm;
end
hold on;
for i = 1:length(N)
plot(viscosity, viscosity_pm(:,i), 'DisplayName', ['Speed (RPM) = ',num2str(N(i))]);
end
xlabel('Viscosity (Pa.s)');
ylabel('Maximum Pressure (MPa)'); legend('show');
댓글 수: 0
채택된 답변
VBBV
2023년 7월 22일
편집: VBBV
2023년 7월 22일
clear;
clc;
r = 0.05; %radius in meter
viscosity = [256E-3, 544E-3, 1200E-3, 3680E-3, 5440E-3]; %viscosity in pa.s
l = 0.08; %length in meter
rm = 0.075; %mean radius
N = [1000,3000,4000]; %speed in rpm
sh = 10E-6; %sh in unit meter
fprintf(' ---------------------------------------------------------------------------------------\n');
fprintf(' |Speed (RPM)\tVelocity (m/s)\t\tViscosity (Pa.s)\tMaximum Pressure(MPa) | \n ');
fprintf('---------------------------------------------------------------------------------------\n');
for i = 1:length(N)
u = ((2.*3.142.*N(i))./60)*rm;
for j = 1:length(viscosity)
ho = sh/1.4142;
pm = ((3*u*viscosity(j)*l*sh)/((2*ho)*(sh+ho)*(sh+(2*ho))))/10^6;
fprintf(' | %d\t\t\t%0.6d\t\t\t%0.6d\t\t\t%0.6d\t |\n', N(i), u, viscosity(j), pm);
end
fprintf(' ---------------------------------------------------------------------------------------\n');
end
figure;
for i = 1:length(N)
u = ((2.*3.142.*N(i))./60)*rm;
for j = 1:length(viscosity)
ho = sh/1.4142;
pm = ((3*u*viscosity(j)*l*sh)/((2*ho)*(sh+ho)*(sh+(2*ho))))/10^6;
viscosity_pm(j,i) = pm;
end
end
viscosity_pm
hold on;
for i = 1:length(N)
plot(viscosity, viscosity_pm(:,i), 'DisplayName', ['Speed (RPM) = ',num2str(N(i))]);
end
xlabel('Viscosity (Pa.s)');
ylabel('Maximum Pressure (MPa)'); legend('show');
댓글 수: 2
VBBV
2023년 7월 22일
you have closed the outer for loop for figures without storing the values for array to be plotted
for i = 1:length(N)
u = ((2.*3.142.*N(i))./60)*rm;
for j = 1:length(viscosity)
ho = sh/1.4142;
pm = ((3*u*viscosity(j)*l*sh)/((2*ho)*(sh+ho)*(sh+(2*ho))))/10^6;
viscosity_pm(j,i) = pm;
end
end % the end for outer for loop
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
