How to fix this. Please help!

조회 수: 1 (최근 30일)
Rizwana
Rizwana 2013년 11월 6일
편집: Azzi Abdelmalek 2013년 11월 6일
//Question: Before interpolation the A matrix data i was unable to execute it because it was throwing error like A(2.6) for diffrent n(always integer) integers. Then i tried interpolating my matrix A . Its not giving proper results. Also i want my final answer to be displayed after for loop
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 , 'nearest');
a=1;
b=9;
n=6;
h=(b-a)/n;
for i = 0:3
ans =0.5*[A1*(a+(i*h)) + A1(a+(i+1)*h)]*h;
end

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 6일
편집: Azzi Abdelmalek 2013년 11월 6일
This line A1= interp1( t , A, t1 , 'nearest') is not correct, t is not defined, use
A1= interp1( time , A, t1 , 'nearest')
Add
a = 1;
b = 9;
n = 4;
h = (b-a)/n;
A = [916.3, 923.6, 933.1, 947.4, 966.2, 986.6, 1008.5, 1031.5, 1051.3 ];
for i = 0:3
res = 0.5 * [ A(a+(i*h)) + A(a+(i+1)*h) ]*h;
disp(res)
end
  댓글 수: 8
Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 6일
I don't think you tried the correct program, copy ant paste the code in my previous comment. It works without errors
Rizwana
Rizwana 2013년 11월 6일
Thank You so much.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by