connect the points of my plot

11 次查看(过去 30 天)
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

回答(1 个)

Niranjan Sundararajan
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

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by