Need help getting right orientation

So they are asking for a 4by5 but i ended up with 5by4 with a 0row as the last row.
Am i doing something wrong?
Below is my code. Thanks in advance
a=5;
b=4;
T1=80;
k=5; %first 5 term
x=[1:1:5];
y=[1:1:4];
for x=1:1:5
for y=1:1:4
T(x,y)=0
for n=1:k
ns=2*n-1;
T(x,y)=T(x,y)+(sin(ns*((pi*x)/a))/ns).*(sinh(ns*((pi*y)/a))/sinh((ns*(pi*b)/a)));
end
T(x,y)=T(x,y)*((4*T1)/pi)
end
end

2 Commenti

  • Am i doing something wrong?
Why do you think so?
As i needed to make a 4x5 matrix with 0 as my last column
But i got a 5x4 matrix with my 0 as my last row instead

Risposte (1)

KSSV
KSSV il 3 Mar 2020
Modificato: KSSV il 3 Mar 2020
You should follow something like this:
a = 5 ; b = 4 ;
T1 = 80 ;
m = 100 ; n = 100 ;
x = linspace(0,a,m) ;
y = linspace(0,b,n) ;
[X,Y] = meshgrid(x,y) ;
T = zeros(m,n) ;
for n = 1:50
T = T+4*T1/pi*(sin((2*n-1)*pi*X/a)/(2*n-1).*sinh((2*n-1)*pi*Y/a)/(sinh((2*n-1)*pi*b/a))) ;
end
pcolor(X,Y,T) ;
shading interp ;
colorbar

Questa domanda è chiusa.

Richiesto:

il 3 Mar 2020

Chiuso:

il 20 Ago 2021

Community Treasure Hunt

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

Start Hunting!

Translated by