フィルターのクリア

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

6 ビュー (過去 30 日間)
Rufiya
Rufiya 2023 年 8 月 14 日
コメント済み: Rufiya 2023 年 8 月 14 日
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
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');
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 Center および File Exchange2-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