Can someone please help! I cannot plot this graph. Multiple 3 line graph.
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Baratganthi Krishnan
el 22 de Jul. de 2023
Comentada: Baratganthi Krishnan
el 22 de Jul. de 2023
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 comentarios
Respuesta aceptada
VBBV
el 22 de Jul. de 2023
Editada: VBBV
el 22 de Jul. de 2023
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 comentarios
VBBV
el 22 de Jul. de 2023
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
Más respuestas (0)
Ver también
Categorías
Más información sobre Graph and Network Algorithms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
