why its giving error? Its saying cant read A1(2.3), its not logical
2 次查看(过去 30 天)
显示 更早的评论
t = 1:9;
t1 = 1 : 0.1 :9;
A = [916.3, 923.6, 933.1, 947.4, 966.2, 986.6, 1008.5, 1031.5, 1051.3];
A1 = interp1(t ,A , t1) ;
a= 1;
b=9;
h= 1.3;
for i = 0:3
res = 0.5*[A1(a+ i*h)+ A1(a + (i+1)*h)]*h
disp('res')
end
0 个评论
回答(2 个)
ES
2013-11-7
编辑:ES
2013-11-7
all Indices in matlab must be positive integers. your h is 1.3 so for all i values it will try to access A1(i.3) which is not correct.
res = 0.5*[A1(a+ i*h)+ A1(a + (i+1)*h)]*h
It might help if you say what you ant to achieve in your code. For example
disp('res')
will not give you desired results. It should be
disp(res)
instead.
3 个评论
ES
2013-11-7
>> size(A1)
ans =
1 81
A1 is a single dimensional array. It has one row and 81 columns. What do you mean by 2nd columns 3 rd reading?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!