フィルターのクリア

What wrong with the code

3 ビュー (過去 30 日間)
kt chua
kt chua 2021 年 10 月 26 日
コメント済み: kt chua 2021 年 10 月 27 日
I have an assignment question which involve matlab to plot the above graph and below are the code I used.
y=linspace(0,6,10);
x=linspace(0,11,10);
[X,Y]=meshgrid(x,y);
U=(400/pi)*symsum((sin((n*pi*X)/11).*sinh(n*pi*Y/11))/(n*sinh((n*pi*6)/11)),n,1,200);
surf(X,Y,U)
and it return the error"Invalid parameter/value pair arguments"
I'm not sure why it display such error and i check by using simpler function like U=X.*Y, it able to plot the graph, so I cannot identify where the error in my original equation as below.
U=(400/pi)*symsum((sin((n*pi*X)/11).*sinh(n*pi*Y/11))/(n*sinh((n*pi*6)/11)),n,1,200);
but command like plot3(X,Y,U) is working .

採用された回答

chris crowley
chris crowley 2021 年 10 月 26 日
Your superfluous use of parentheses made it hard to spot, but you have the wrong number of them in your calculation of U. Take a closer look.
Also, you could do this without needing the symbolic toolbox like this:
y=linspace(0,6,10);
x=linspace(0,11,10);
[X,Y]=meshgrid(x,y);
U = zeros(size(X));
for n = 1:2:200
U = U + sin(n*pi*X/11).*sinh(n*pi*Y/11)/ (n*sinh(n*pi*6/11));
end
U = (400/pi)*U;
surf(X,Y,U)
  1 件のコメント
kt chua
kt chua 2021 年 10 月 27 日
Thanks for spoting my mistake. The for loop command indeed cleaner and much easier to perform the function for Odd value of n.

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by