Plot a variable with different values at different time intervals.

2 ビュー (過去 30 日間)
Somadina F. Ezeiruaku
Somadina F. Ezeiruaku 2019 年 1 月 30 日
コメント済み: Sean Watts 2019 年 3 月 29 日
Hi
I have a table below that assigns different values of r at different time interval. How can I do this please?
Screen Shot 2019-01-30 at 2.27.10 PM.png
  1 件のコメント
Luna
Luna 2019 年 1 月 30 日
What have you done so far? What does it mean 0 - < 1 ? From 0 to 1 ?

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

採用された回答

madhan ravi
madhan ravi 2019 年 1 月 30 日
編集済み: madhan ravi 2019 年 1 月 30 日
Logical indexing is more efficient :
t=0:.001:8;
r=zeros(size(t));
r(t>=0 & t<1)=100;
r(t>=1 & t<4)=250;
r(t>=4 & t<6)=330;
r(t>=6 & t<8)=100;
r(t==8)=0;
plot(t,r)
  3 件のコメント
madhan ravi
madhan ravi 2019 年 3 月 29 日
Not sure what you're asking, perhaps you mean:
idx = t>=0 & t<1;
r(idx)=(t(idx)/100)^2
Sean Watts
Sean Watts 2019 年 3 月 29 日
Thanks for reply,
I am very new to Matlab but have to use it for a module in my civ eng degree.
I essentially need to make a modulating function (phi(t)) to apply to a larger variable.
with t=0:20 seconds and beta=9/10; t1=2.5/beta; t2=11.5/beta;
boundarys;
phi(t)= (t/t1).^2 when t<t1
phi(t)= 1 when t1=<t=<t2
phi(t)= exp(-beta*(t-t2) when t>t2

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by