How to fill area under the stairstep graph plot in MATLAB ?
5 次查看(过去 30 天)
显示 更早的评论
Hi All,
Please could anyone help me fill the area under the stairstep graph plot created from the attached TestData.m file using the excel data sheet in the attached zip file.
I tried intially using the area function to fill the area under the stairstep graph, but unfortunately the graph output becomes too noiser and does not any longer represent as stairstep graph.
Thanks in advance and looking forward to hear from you.
0 个评论
采纳的回答
Sulaymon Eshkabilov
2023-8-14
Hi,
Here is how you can solve this exercise (use your MS EXcel file, then no warnings will pop up!):
FZ = unzip('Final Filtered Catalogued Object Data - Copy.zip');
rawTable = readtable(FZ{1,1},'Sheet','Final Data');
x = rawTable.ApogeeAltitude; %: get the excel column, ApogeeAltitude(Km) (header name)
y1 = rawTable.RocketBody; %: get the excel column, RocketBody (header name)
y2 = rawTable.Debris; %: get the excel column, Debris (header name)
y3 = rawTable.Payload; %: get the excel column, Payload (header name)
%%
figure;
s=stairs(x,y2);
s.Color = 'red';
set(gca, 'ylim', [0 100]);
set(gcf,'color','w');
grid on
grid minor
hold on
BB = min(s.YData);
X = [s.XData(1),repelem(s.XData(2:end),2)];
Y = [repelem(s.YData(1:end-1),2),s.YData(end)];
fill([X,fliplr(X)],[Y,BB*ones(size(Y))], 'y')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!