Effacer les filtres
Effacer les filtres

connect the points of my plot

8 vues (au cours des 30 derniers jours)
Nicholas DeGarmo
Nicholas DeGarmo le 16 Fév 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

Réponses (1)

Niranjan Sundararajan
Niranjan Sundararajan le 2 Juin 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

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by