Info

This question is closed. Reopen it to edit or answer.

I am getting a message saying that 'too many input arguments' . What should I do.

1 view (last 30 days)
if true
% code
end%Problem2
clc;
clear;
set(0, 'defaultaxesfontname','times');
set(0, 'defaultaxesfontsize',20);
figID = 1;
L= 1;
Nx = 51;
dx= L/Nx;
x = dx*linspace(0,Nx-1,Nx).';
PeriodicFlag = 1;
a = 1;
%operator
T = 10;
Nt = 11;
dt = T/(Nt-1);
%spacedef and casedef strings
spacedef_1 = 'Central4a';
spacedef_2 = 'Central4b';
spacedef_3 = 'Central4c';
casedef = 'LinearAdvection';
%gausian Pulse
u0 = exp(-(x-0.5).^2/0.1^2);
*%solve the ODE
[t,u1,x,D1] = integrator(L,Nx,T,PeriodicFlag,Nt,spacedef_1,casedef,u0,a);
[t,u2,x,D2] = integrator(L,Nx,T,PeriodicFlag,Nt,spacedef_2,casedef,u0,a);
[t,u3,x,D3] = integrator(L,Nx,T,PeriodicFlag,Nt,spacedef_3,casedef,u0,a);
%Compute eigenvalues*
M1 = -D1*a;
M2 = -D2*a;
M3 = -D3*a;
j=0:Nx-1;
b1j = M1(1,:);
b2j = M2(1,:);
b3j = M3(1,:);
for m = 1:Nx
E = exp(1i*2*pi*j*(m-1)/Nx);
lamda_1(m) = dot(b1j,E);
lamda_2(m) = dot(b2j,E);
lamda_3(m) = dot(b3j,E);
end
figure(figID); clf; figID + 1;
plot(real(lamda_1),imag(lamda_1),'b+',...
real(lamda_2),imag(lamda_2),'ko',...
real(lamda_3),imag(lamda_3),'r^')
title('EigenValues')
legend('\lamda_m by Central 4','\lamda_m by biased','\lamda_m by implicit')
figure(figID); clf; figID + 1;
for n = 1:length(t)
j = n-1;
[xx,ii] = sort(mod(x*a*t(n),1));
plot(xx,u0(ii),'k-',x,u1(n,:),'b-+',x,u2(n,:),'k-o',x,u3(n,:),'r-^')
legend('Exact Solution','Numerical Central4','Numerical biased','Numerical implicit')
axis([-0.1 1.1 -0.5 1.1]);
pause(0.1)
end
figure(figID); clf; figID = figID + 1;
set(0, 'defaultaxesfontname','times');
set(0, 'defaultaxesfontsize',8);
for n = 2:11
j = n-1;
[xx,ii] = sort(mod(x+a*t(n),1));
subplot(5,2,j)
plot(xx,u0(ii),'k-',x,u1(n,:),'b-+',x,u2(n,:),'k-o',x,u3(n,:),'r-^')
legend('Exact Solution','Numerical Central4','Numerical biased','Numerical implicit')
axis([-0.1 1.1 -0.5 1.1]);
end

Answers (0)

Community Treasure Hunt

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

Start Hunting!