How to fill area under the stairstep graph plot in MATLAB ?

6 次查看(过去 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.

采纳的回答

Sulaymon Eshkabilov
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');
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
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 CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by