Interpolation and getting errors

1 回表示 (過去 30 日間)
C Mck
C Mck 2016 年 7 月 8 日
コメント済み: C Mck 2016 年 7 月 8 日
I am trying to run the piece of code below
function output = AtheroEqn2016(t,y,e)
fid= fopen('ifng.txt','r');
format longg;
A = textscan(fid, ['%s', repmat('%f', 1 , 25)], 'HeaderLines', 1);
e= [A{2:end}];
time=[0 30 60 90 120 150 180 210 240 270 300 330 360 390 420 450 480 510 540 570 600 630 660 690 720]
e= (((t-time(floor(t/30)))/(time(floor(t/30)+1)-time(floor(t/30))))*e1) + (((time(floor(t/30)+1)-t)/(time(floor(t/30)+1)-time(floor(t/30)+1)))*e0)
howver when it gets to the last line I get the following error, _ * _ Subscript indices must either be real positive integers or logicals._*_
Does anyone know why this is and how I could fix it?
Thanks

採用された回答

Jan Orwat
Jan Orwat 2016 年 7 月 8 日
編集済み: Jan Orwat 2016 年 7 月 8 日
Note, you are trying to access time(0) when t<30. Matlab index arrays starting with 1. Probably changing floor(t/30) to ceil(t/30) or to floor(t/30)+1 would fix this error.
  2 件のコメント
Jan Orwat
Jan Orwat 2016 年 7 月 8 日
btw. you will get the same time vector by typing time = 0:30:720;
C Mck
C Mck 2016 年 7 月 8 日
thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by