Azzera filtri
Azzera filtri

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

6 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Sulaymon Eshkabilov
Sulaymon Eshkabilov il 14 Ago 2023
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')

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by