Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to convert this c code in to matlab.

조회 수: 3 (최근 30일)
RAVI MANDAVA
RAVI MANDAVA 2016년 3월 13일
마감: MATLAB Answer Bot 2021년 8월 20일
for s=0:s<n/h -1:s+1
F1 = (X13(s+1) - X13(s))/h;
F2 = (X14(s+1) - X14(s))/h;
F3 = (X15(s+1) - X15(s))/h;
F4 = (X16(s+1) - X16(s))/h;
tt = tt + (n/(kkk -1));
end
this is the error i am getting
Undefined function or variable 's'.
Error in test4 (line 479)
for s=0:s<n/h -1:s+1
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 3월 13일
You do not appear to have posted the C code to be converted.

답변 (1개)

Roger Stafford
Roger Stafford 2016년 3월 13일
편집: Roger Stafford 2016년 3월 13일
In the first place, the arrays X13, X14, and X16 will have to be changed to start at index 1, not 0. Matlab does not allow an index of 0. Then your code in matlab would be:
for s = 1:1:n/h % 1:n/h would do just as well
F1 = (X13(s+1) - X13(s))/h;
F2 = (X14(s+1) - X14(s))/h;
F3 = (X15(s+1) - X15(s))/h;
F4 = (X16(s+1) - X16(s))/h;
tt = tt + (n/(kkk -1));
end
In matlab this computation of F1 through F4 would be uselss unless you provided some method of storing these results as you go along. (That is also true of C.)
  댓글 수: 1
RAVI MANDAVA
RAVI MANDAVA 2016년 3월 15일
Thanking you sir

이 질문은 마감되었습니다.

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by