connect the points of my plot

5 views (last 30 days)
Nicholas DeGarmo
Nicholas DeGarmo on 16 Feb 2022
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

Answers (1)

Niranjan Sundararajan
Niranjan Sundararajan on 2 Jun 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

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!