How can I solve the following code?

조회 수: 1 (최근 30일)
Altin Guberi
Altin Guberi 2017년 6월 7일
댓글: Walter Roberson 2017년 6월 7일
% 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