Piece-wise Functions

17 ビュー (過去 30 日間)
Vivek
Vivek 2022 年 10 月 6 日
回答済み: Sam Chak 2022 年 10 月 6 日
Piecewise functions are very useful in representing phenomena that vary differently for different ranges of the independent variable. The variation of velocity (m/min) of a rocket as a function of time can be represented by piecewise functions as shown below:
Develop a pseudocode, flowchart and code to compute velocity from time, t = - 5 to 50 min and plot time vs. velocity. The plot should be properly formatted. It must contain a title, x and y labels and a legend.
  2 件のコメント
Sam Chak
Sam Chak 2022 年 10 月 6 日
You forgot to attach your MATLAB code.
Having the code makes it easier to be checked.
Star Strider
Star Strider 2022 年 10 月 6 日
@Vivek — Do we get the credit if we do your homework problems for you?

サインインしてコメントする。

回答 (1 件)

Sam Chak
Sam Chak 2022 年 10 月 6 日
Let's try something very basic.
t1 = -5:0.1:0;
t2 = 0:0.1:10;
t3 = 10:0.1:20;
t4 = 20:0.1:30;
t5 = 30:0.1:50;
% Segment 1
v1 = zeros(1, length(t1));
plot(t1, v1), hold on
% Segment 2
v2 = 11*t2.^2 - 5*t2;
plot(t2, v2),
% Segment 3
v3 = 1100 - 5*t3;
plot(t3, v3),
% Segment 4
v4 = 50*t4 + 2*(t4 - 20).^2;
plot(t4, v4),
% Segment 5
v5 = 1700*exp(-0.2*(t5 - 30));
plot(t5, v5), grid on
xlabel('t')
ylabel('v(t)')

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by