Filter löschen
Filter löschen

How can I solve the following code?

1 Ansicht (letzte 30 Tage)
Altin Guberi
Altin Guberi am 7 Jun. 2017
Kommentiert: Walter Roberson am 7 Jun. 2017
% 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 Kommentar
Walter Roberson
Walter Roberson am 7 Jun. 2017
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by