connect the points of my plot

8 visualizaciones (últimos 30 días)
Nicholas DeGarmo
Nicholas DeGarmo el 16 de Feb. de 2022
Respondida: Niranjan Sundararajan el 2 de Jun. de 2023
I need to connect my point of my plot, but I am using an equation to get these points and I do not know how to connect the points with a line while still keeping the individual data points
clc
clear
close all
T_0 = 518.7;
S = 198.72;
u_0 = 3.36*10^(-7);
for T = [35:5:120]
u = ((u_0)*((T/T_0)^1.5)*((T_0 + S)/(T+S)));
plot(T,u,"o"),
grid on, hold on
end

Respuestas (1)

Niranjan Sundararajan
Niranjan Sundararajan el 2 de Jun. de 2023
Rather than plotting values individually using a for loop, you can straight away perform the computations in one step using matrix operators (.* .^ ./ etc.). This way, your results will be stored in a single array and the plot becomes a single line.
Also, when plotting, you need to use the "o-" command where you have currently used the "o" command. "o" stands for circular markers, so you will be getting a plot that only has circular markers. To connect them with a line, you need to add the "-" symbol along with it.
I have attached my code here, and it gives the same result as yours. Check it out. Also, in case you necessarily need to use a for loop, you can append the values generated at each for loop iteration to an array (say T_plot and u_plot) and finally plot these values.
T_0 = 518.7;
S = 198.72;
u_0 = 3.36*10^(-7);
T = 35:5:120;
u = ((u_0)*((T./T_0).^1.5).*((T_0 + S)./(T+S)));
plot(T,u,"o-");
grid on, hold on

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by