Borrar filtros
Borrar filtros

What wrong with the code

3 visualizaciones (últimos 30 días)
kt chua
kt chua el 26 de Oct. de 2021
Comentada: kt chua el 27 de Oct. de 2021
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 .

Respuesta aceptada

chris crowley
chris crowley el 26 de Oct. de 2021
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 comentario
kt chua
kt chua el 27 de Oct. de 2021
Thanks for spoting my mistake. The for loop command indeed cleaner and much easier to perform the function for Odd value of n.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by