Convert a for loop from MathCAD to Matlab

3 ビュー (過去 30 日間)
Sean Raffetto
Sean Raffetto 2016 年 8 月 17 日
コメント済み: dpb 2016 年 8 月 18 日
I have to solve for sigma c in the attached pdf and need some help converting it from Mathcad to Matlab. Can someone help me translate the code to Matlab? Here's the sizes of m,n,j:
%m = 1:71;
%n = 1:41;
%j = 1:512;
Thanks!
  2 件のコメント
dpb
dpb 2016 年 8 月 17 日
And your attempt is where and you got stuck on what part, precisely???
dpb
dpb 2016 年 8 月 17 日
編集済み: dpb 2016 年 8 月 18 日
What is the pseudo-code for the a conditional term?; I can't decipher the Matchcad-ese, sorry. Specifically, if I presume it's something like
a=dp/6;
a(0)=2*p(0)+p(1);
a(N-1)=2*p*(N-1)+p(N-2)*p(n-1)+4*p(n)+p(n+1);
then since the if implies n==N, then p(n+1) would seem to have a bounds problem???
And, of course, what are p, delta-p, k, etc., etc., ...

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

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 8 月 17 日
for m ε 0..M - 1
translates to the MATLAB code
for m = 0 : M - 1
However, keep in mind that in MATLAB, subscripts start at 1 instead of 0, so anywhere you wanted to use m as a subscript you would need to add 1 to it. Mostly you would end up writing as
for m = 1 : M
  3 件のコメント
Walter Roberson
Walter Roberson 2016 年 8 月 18 日
What is the question then?
dpb
dpb 2016 年 8 月 18 日
"... work ahead of this snippet that's not functioning correctly."
And we were to be able to divine that how, precisely???

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

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by