Sum of Maple to MATLAB
古いコメントを表示
Hi All,
There is a saying "A pee to an ant is flooding".... I guess my question appears simple but being new to MATLAB, couldn't find my way. Seeking some help...
Lm = [1 2 3]';
Um = [4 5 6]';
Maple:
sum(Lm[p,1] * sum(Lm[q,1] * (Um[p,1] - Um[q,1]),q=1..3), p=1..3)
What will be the equivalent MATLAB for the above?
Thank you.
1 件のコメント
Matt Fig
2011 年 5 月 14 日
I would have to know what that Maple command did first! Since this is a MATLAB site, it is possible that nobody on here knows what that Maple command does...
採用された回答
その他の回答 (3 件)
Andrei Bobrov
2011 年 5 月 14 日
more variant
Lm.'*bsxfun(@minus,Um,Um.')*Lm
Matt Fig
2011 年 5 月 14 日
It would help, for those of us who do not have Maple and consequently do not know what the result of that Maple command is, if you would show the expected output. Even if you have to make a simple example and create the output by hand, show inputs and expected outputs.
The best I can guess would be:
S = 0; % This is the result you want at the end.
for p = 1:3
tmp = 0;
for q = 1:3
tmp = tmp + Lm(q) * (Um(p)-Um(q));
end
S = S + tmp*Lm(p);
end
S % Look at the final result...
カテゴリ
ヘルプ センター および File Exchange で MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!