Why is the line of y2 always a flat line at x-axis instead of a straight line with negative gradient?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Rubayet
el 10 de Oct. de 2023
Comentada: Image Analyst
el 11 de Oct. de 2023
x = linspace(0, 20, 100);
y1 = (exp(x)-1)/10;
y2 = -x+3;
plot(x, y1, 'r');
hold on;
plot(x, y2, 'g');
xlabel('Diode Voltage');
ylabel('Diode Current');
title('Plot of I_D and V_D');
0 comentarios
Respuesta aceptada
Image Analyst
el 10 de Oct. de 2023
It's flat because of hte scale of your y axis. Look -- it goes from -1 to 50 million, while y2 goes from 3 to -17. How do you expect the line to look when it only changes height of 20 in a scale of 50 million?
If you want to see y2, plot it on a separate axes.
3 comentarios
Image Analyst
el 11 de Oct. de 2023
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.
Más respuestas (1)
Walter Roberson
el 10 de Oct. de 2023
x = linspace(0, 20, 100);
y1 = (exp(x)-1)/10;
y2 = -x+3;
%plot(x, y1, 'r');
hold on;
plot(x, y2, 'g');
xlabel('Diode Voltage');
ylabel('Diode Current');
title('Plot of I_D and V_D');
Which is to say that your y1 goes up to about 5 x 10^7. If we were to guess that the plot is about 500 pixels high then that would mean that there would be 5e7/5e2 = 1e5 data units per pixel. Your y2 covers about 20 data units, so on the scale of 0 to 5*10^7 it occupies about 20/1e5 = 0.0002 pixels of y difference. Which is not enough to be visible.
Ver también
Categorías
Más información sobre 2-D and 3-D 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!