필터 지우기
필터 지우기

Blank plot in matlab

조회 수: 58 (최근 30일)
MOUNIBA REDAH
MOUNIBA REDAH 2019년 6월 25일
댓글: Star Strider 2019년 6월 27일
hello can you please help me?? when i type this code i only get a balnk plot
i don`t know where is my mistake
the code
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]=meshgrid (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')

채택된 답변

Star Strider
Star Strider 2019년 6월 25일
The immediate problem is:
plot(t,length(Z0));
since the length function will produce a scalar, and you can only plot a scalar using a marker. (The plot function plots lines between two defined points, and a scalar has only one.)
Beyond that, however, ‘Z0’ is not a function of ‘t’, and has entiely different dimensions as the result, so you cannot plot it as a function of ‘t’.
This works:
plot(Z0);
however it is likely not the result you want. You need to fix that problem.
  댓글 수: 22
MOUNIBA REDAH
MOUNIBA REDAH 2019년 6월 27일
편집: MOUNIBA REDAH 2019년 6월 27일
hello Star Strider a colegue had help me and give me some information the reason of Loops in my code is because there is a summuation in my equation
And gave me the code of It only It is not using Plot ,This example in using SURF because the result that gave me is in 3D
My qustion it is possible to modify in this code in order to plot the graph I Want I mean to change the eqaution above by this one : Capturesi.PNG
Ps The code attached
Star Strider
Star Strider 2019년 6월 27일
I have no clue as to what you want.
Try this:
t = linspace(0, 1); % Use Correct Time Limits
omega = rand(4); % Use Correct Values
for k1 = 1:4
for k2 = 1:4
Z(k1,k2,:) = acos(omega(k1,k2)*t);
end
end
Zs = sum(sum(Z,2),1);
Zs = squeeze(Zs);
figure
plot(t, Zs)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by