How can i combine 5 curves in one figure?
2 次查看(过去 30 天)
显示 更早的评论
Hello!
I have 5 figures, I want to combine the curves in such a way that only one curve can be seen .
this is the code
Xu=linspace(0,12,60);
Yu=linspace(0,10,60);
figure()
p1=plot(Xu,Yu)
xlabel('temps(min)')
ylabel('X(km)')
p1.LineWidth = 1.5;
grid on
%----------
Xu=linspace(12,24,60);
Yu=linspace(10,0,60);
figure()
p1=plot(Xu,Yu)
xlabel('temps(min)')
ylabel('X(km)')
p1.LineWidth = 1.5;
grid on
%-------------------
Xu=linspace(24,36,60);
Yu=linspace(0,10,60);
figure()
p1=plot(Xu,Yu)
xlabel('temps(min)')
ylabel('X(km)')
p1.LineWidth = 1.5;
grid on
%----------------
Xu=linspace(36,48,60);
Yu=linspace(10,0,60);
figure()
p1=plot(Xu,Yu)
xlabel('temps(min)')
ylabel('X(km)')
p1.LineWidth = 1.5;
grid on
%-------------
Xu=linspace(48,60,60);
Yu=linspace(0,10,60);
figure()
p1=plot(Xu,Yu)
xlabel('temps(min)')
ylabel('X(km)')
p1.LineWidth = 1.5;
grid on
0 个评论
采纳的回答
Sam Chak
2022-9-6
I didn't clean up the code. But more or less, the hold is used. You can also set the LineColor so that it appears as a piecewise function.
Xu=linspace(0,12,60);
Yu=linspace(0,10,60);
plot(Xu,Yu, 'LineWidth', 1.5), hold on
% xlabel('temps(min)')
% ylabel('X(km)')
% p1.LineWidth = 1.5;
% grid on
%----------
Xu=linspace(12,24,60);
Yu=linspace(10,0,60);
plot(Xu,Yu, 'LineWidth', 1.5), hold on
% xlabel('temps(min)')
% ylabel('X(km)')
% p1.LineWidth = 1.5;
% grid on
%-------------------
Xu=linspace(24,36,60);
Yu=linspace(0,10,60);
plot(Xu,Yu, 'LineWidth', 1.5), hold on
% xlabel('temps(min)')
% ylabel('X(km)')
% p1.LineWidth = 1.5;
% grid on
%----------------
Xu=linspace(36,48,60);
Yu=linspace(10,0,60);
plot(Xu,Yu, 'LineWidth', 1.5), hold on
% xlabel('temps(min)')
% ylabel('X(km)')
% p1.LineWidth = 1.5;
% grid on
%-------------
Xu=linspace(48,60,60);
Yu=linspace(0,10,60);
plot(Xu,Yu, 'LineWidth', 1.5), hold off
xlabel('temps(min)')
ylabel('X(km)')
grid on
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!