1
votes

I am trying to plot Z0 in term of t I get this error Matrix dimensions must agree. I know that ‘T’ is a scalar, and ‘X’ and ‘Y’ are (51x26) matrices, and ‘t’ is a (1x501) vector.It is not possible to multiply them, because they are not conformable to matrix multiplication I need a solution please I am new to MATLAB

sigma0=0;
el= 0.5;
L= 1 ;
h= 0.5 ;
a= 1;
N= 3;
g=10;
rho=1000;
Z0=0;
t=0:0.01:5;
x=0:0.02:el;
y=0:0.02:L;
[X,Y]=mesh grid (x,y);
sigma=0;
T=3*pi/4;
for n=0:N
    for m=0:N
        A=pi*((m/el)^(2)+(n/L)^(2))^(0.5);
        B=(g*A+(sigma/rho)*A^3)*atan(A*h);
        C=B^(0.5); 
        Z=a*cos(C.*T).*cos((m*pi/el).*X).*cos((n*pi/L).*Y);
        Zs=Z0+Z;
        Z0=Zs;

    end
end
  m=3;
  n=4;

A=pi*((m/el)^(2)+(n/L)^(2))^(0.5);
B0=(g*A+(sigma0./rho)*A^3)*atan(A*h);
C0=(B0.^(0.5)); 
Z0=(a.*cos(C0.*T)).*cos((m*pi/el).*X).*(cos((n*pi/L).*Y));
figure
subplot(221)
plot(t,length(Z0));
xlabel(' temps s');
ylabel(' élévation z(x,y)y');
title(' sans tension superficielle');
legend('sigma0') 

The result I expect to see a sinusoidal figure

1

1 Answers

0
votes

I think all you need is replacing plot(t,length(Z0)); with plot(1:length(Z0), Z0);

I am not getting an error message, and I can't see where you try to multiple by t.
Execute clear all just in case...

Except that, you posted a syntax error [X,Y]=mesh grid (x,y); should be [X,Y]=meshgrid (x,y);.

Replace plot(t,length(Z0));
With: plot(1:length(Z0), Z0);

Here is the result:

Subplot