How can I solve the following code?

1 次查看(过去 30 天)
% Ekuacioni hiperbolik i lëkundjeve të kordës- metoda Furie,
clc;clear;close all
global a L H xp tp
a=1; L=1; H=0.02;
T=5; m=10; N=50;
x=linspace(0,L,m+1); t=linspace(0,T,N+1);
[xx,tt]=meshgrid(x,t);
u=ztf1(xx,tt);
figure(1)
surf(xx,tt,u);
pause(7)
figure
dt=0.05;
for t=0:dt:T
tp=t
figure(2)
fplot('ztfx',[0 1])
axis([0 1 -0.5 0.5]) %grafikon profilin e kordë në mom.t
pause(.001)
end
pause(7)
xp=0.5;
figure(3)
fplot('ztfx',[0 T],'r') %grafikon trajektoren e pikës xp=0.5 të kordës
The function is
function u=ztf(x,t)
global a L H
NT=100;
s=0;
for n=0:NT
c=(2*n+1)*pi/L;
un=1/(2*n+1)^3*sin(c*x).*cos(a*c*t);
s=s+un;
end
u=32*H/pi^3*s;
however I am not being able to get the function plots . I get constantly these errors: Warning: Error updating FunctionLine.
The following error was reported evaluating the function in FunctionLine update: Undefined function or variable 'xp'. even though xp is defined. So how do I solve this?
  1 个评论
Walter Roberson
Walter Roberson 2017-6-7
You ask to fplot ztfx but you show us the code for ztf
I notice that your ztf takes two parameters. fplot() is for use with functions that take only one parameter.

请先登录,再进行评论。

回答(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