connect the points of my plot
조회 수: 8 (최근 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
댓글 수: 0
답변 (1개)
Niranjan Sundararajan
2023년 6월 2일
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!