フィルターのクリア

My graph isn't picking up my time increments. How can I fix it? My loop generates my x values, but I'm trying to graph them over time.

1 回表示 (過去 30 日間)
% Ch=(Chd-Chs)e^(-t/ts)+Chs equation from C.3
clear
Ts=30; % ms
Td=60; % ms
Chs=.001; % L/mmhg
Chd=.015; % L/mmhg
N=800; % number of elements
t=0:1:800; % all time values together
for i=0:N
if any(i==0:99)
Ch(i+1)=Chd; % starts at .015 L/mmhg in chd phase
elseif i>99 & i<350
Ch(i+1)=(Chd-Chs)*exp((-t(i))/Ts)+Chs; % switches to chs
elseif i>349
Ch(i+1)=(Chs-Chd)*exp((-t(i))/Ts)+Chd; % switches back to chd
end
end
timebase=0:.01:8; % putting back in s
plot(timebase,Ch)
grid on
ylim([0 .02])
xlabel('time(s)')
ylabel('Ch (L/mmHg')
It's not picking up my y values, I'm trying to graph this over time and it's not working, it shouldn't be a straight line up and down, but its turning out that way.
  4 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 9 月 25 日
Can you attach the reference equations you are trying to plot?
BAILEY MCMASTER
BAILEY MCMASTER 2023 年 9 月 25 日
The reference equations are the equations of the loop, compliance during systole and diastole. I'm doing a time interval showing the changes of compliance over an interval.

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

採用された回答

KSSV
KSSV 2023 年 9 月 25 日
clear
Ts=30; % ms
Td=60; % ms
Chs=.001; % L/mmhg
Chd=.015; % L/mmhg
N=800; % number of elements
t=0:1:N ; % all time values together
Ch = zeros(1,N) ;
for i=1:length(Ch)+1
if i<=99
Ch(i)=Chd; % starts at .015 L/mmhg in chd phase
elseif i>99 && i<350
Ch(i)=(Chd-Chs)*exp((-t(i))/Ts)+Chs; % switches to chs
else
Ch(i)=(Chs-Chd)*exp((-t(i))/Ts)+Chd; % switches back to chd
end
end
timebase=0:.01:8; % putting back in s
plot(timebase,Ch)
grid on
ylim([0 .02])
xlabel('time(s)')
ylabel('Ch (L/mmHg')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by