I want to draw graph. use 'for/while-end loop' and use 'plot' just one time
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
kom gaepyo
el 13 de Mayo de 2021
Comentada: kom gaepyo
el 13 de Mayo de 2021
%06_Diffusion
C0 = 0.2; % wt%
Cs = 1.0;
D = 2.6e-11;
x = 0:0.1:10; % mm
x = x./1000; % meter
t1 = 10*3600;
Cxt1 = C0 + (Cs - C0) *(1-erf(x./(2*sqrt(D*t1))));
plot (x.*1000,Cxt1,'-r','Linewidth',2)
hold on
t2 = 20*3600;
Cxt2 = C0 + (Cs - C0) *(1-erf(x./(2*sqrt(D*t2))));
plot (x.*1000,Cxt2,'-g','Linewidth',2)
t3 = 40*3600;
Cxt3 = C0 + (Cs - C0) *(1-erf(x./(2*sqrt(D*t3))));
plot (x.*1000,Cxt3,'-b','Linewidth',2)
t4 = 100*3600;
Cxt4 = C0 + (Cs - C0) *(1-erf(x./(2*sqrt(D*t4))));
plot (x.*1000,Cxt4,'-k','Linewidth',2)
hold off
title('\fontname{Arial}\fontsize{24} Time Dependent Carbon Profiles')
ylabel('\fontname{Arial}\fontsize{20} Concentration(%)')
xlabel('\fontname{Arial}\fontsize{20} Distance (mm)')
legend('10 hr', '20 hr', '40 hr', '100 hr','FontSize',18)
axis ([0 10 0 1.2])
grid on
ax1 = gca;
set(ax1,'XColor','k','YColor','k','Fontname','Arial','FontSize',18)
i want to chage-> use 'for/while end loop' and use only one 'plot'
0 comentarios
Respuesta aceptada
David Fletcher
el 13 de Mayo de 2021
Something like:
%06_Diffusion
clear
C0 = 0.2; % wt%
Cs = 1.0;
D = 2.6e-11;
x = 0:0.1:10; % mm
x = x./1000; % meter
indexer=1;
for factor=[10 20 40 100]
t = factor*3600;
Cxt(indexer,:) = C0 + (Cs - C0) *(1-erf(x./(2*sqrt(D*t))));
plot(x.*1000,Cxt(indexer,:),'-','Linewidth',2)
hold on
indexer=indexer+1;
end
title('\fontname{Arial}\fontsize{24} Time Dependent Carbon Profiles')
ylabel('\fontname{Arial}\fontsize{20} Concentration(%)')
xlabel('\fontname{Arial}\fontsize{20} Distance (mm)')
legend('10 hr', '20 hr', '40 hr', '100 hr','FontSize',18)
axis ([0 10 0 1.2])
grid on
ax1 = gca;
set(ax1,'XColor','k','YColor','k','Fontname','Arial','FontSize',18)
hold off
Más respuestas (0)
Ver también
Categorías
Más información sobre Line Plots 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!