# plotting multiple line graphs in one plot

3 visualizaciones (últimos 30 días)
Hesam Jokar el 1 de Jun. de 2021
Comentada: Hesam Jokar el 2 de Jun. de 2021
Hey. I was writing a code to show efficiency of thermoelectric generators in one plot. tc is constant in each statement, first z changes and for each z, I want to plot a line based on the th variation. each line, for instance, z=0.5 and th from 300 to 1250 has a specific color for readability.
tc(1:20)=298;th=300:50:1250;figure;hold on;
for t=1:20
z(t)=t./4;
for i=1:20
etha(i)=((th(i)-tc(i))./th(i)).*((sqrt(1+((z(t).*th(i)+tc(i))./2))-1)./...
((sqrt(1+((z(t).*th(i)+tc(i))./2))-(tc(i)/th(i)))));
ln=plot(th(i),etha(i));
ln.Color=(1./t).*[1 1 1];
ln.LineWidth=2;
ln.Marker='*';
end
end
hold off
the output is like this
but I desire for an output like this
anyone has any suggestion? I know I'm amateur....
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

David Fletcher el 1 de Jun. de 2021
Might need some more tinkering - this is limited to 7 lines rather than the 20 you have in your code
tc(1:20)=298;
th=300:50:1250;
for t=1:7
z(t)=t./4;
for i=1:20
etha(t,i)=((th(i)-tc(i))./th(i)).*((sqrt(1+((z(t).*th(i)+tc(i))./2))-1)./...
((sqrt(1+((z(t).*th(i)+tc(i))./2))-(tc(i)/th(i)))));
end
end
ln=plot(th,etha,'*-','LineWidth',2);
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Hesam Jokar el 2 de Jun. de 2021
Thanks. This resolved my issue.

Iniciar sesión para comentar.

### Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

R2018b

### Community Treasure Hunt

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

Start Hunting!

Translated by