why its giving error? Its saying cant read A1(2.3), its not logical

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

답변 (2개)

ES
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

Rizwana
Rizwana 2013년 11월 7일
편집: Rizwana 2013년 11월 7일
when it shows A1(2.3) how should i code it so that it reads 2nd columns 3 rd reading?
>> 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?
My mistake. I want to excess 23(2.3) column now. Dont know how to do it. Will try arranging my data in 2D array. If i get stuck again will get back to you. Thank You

댓글을 달려면 로그인하십시오.

sidra
sidra 2013년 11월 7일

0 개 추천

Reading up about matrix indexing will be helpful in your case. Try the link below:

카테고리

도움말 센터File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

질문:

2013년 11월 7일

댓글:

2013년 11월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by