How to plot a graph with y-axis values that can be incremental?
Show older comments
I was trying to figure out on how to plot the graph where y-axis values would be increase.
Starting code:
T_start1 = {182 444 392 201 155}; %start time (x-axis)
T_end = {728 938 674 638 702}; %end time (x-axis)
figure;
xdata = [cell2mat(T_start1); cell2mat(T_end)];
nT = size(xdata,2);
ydata = [1:nT; 1:nT; NaN(1,nT)];
xdata(end+1,:) = NaN;
plot(xdata(:),ydata(:),'.-r','LineWidth',2,'MarkerSize',8);

My intention is to get this kind of graph (blue line). Is this possible?

Current code:
T_start1 = {182 444 392 201 155}; %start time (x-axis)
T_end = {728 938 674 638 702}; %end time (x-axis)
P_array = {15 15 6 6 15}; %y-axis
figure;
xdata = [cell2mat(T_start1); cell2mat(T_end)];
nT = size(xdata,2);
ydata = [cell2mat(P_array); cell2mat(P_array); NaN(1,nT)];
xdata(end+1,:) = NaN;
plot(xdata(:),ydata(:),'.-r','LineWidth',2,'MarkerSize',8);

However, the output that I obtained wasn't the expected graph I want it to look like. Any help appreciated. Thanks in advance!
Accepted Answer
More Answers (0)
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
