How to fix this error?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I tried to run below script but "The grid vectors do not define a grid of points that match the given values." error is appeared and it is related to
z1=interp2(T,x,Z,T1,x1);
So how I can fix it?
L=5;
c=1;
n=100;
dt=0.005;
tf=5;
h=L/n;
l=dt*c/h;
l2=l^2;
M=l2*(diag(ones(n,1),1)+diag(ones(n,1),-1));
x=linspace(0,L,n+1);
f=x.*sin(4*pi*x/L);
g=0*x;
t=0;
w=f;
z=(1-l2)*f+f/2*M+dt*g;
t=t+dt;
Z=[];
T=[];
while t<tf
u=2*(1-l2)*z+z*M-w;
z=u;
Z=[Z,z];
T=[T,t];
w=z;
t=t+dt;
end
T1=linspace(0,tf,100);
x1=linspace(0,L,100);
z1=interp2(T,x,Z,T1,x1);
surf(x1,T1,z1);
axis([0 L 0 tf -5 5]);
xlabel('position')
ylabel('time')
zlabel('temperetur')
1 commentaire
KSSV
le 11 Mai 2017
Read the documentation of interp2....and then call the function.
z1=interp2(T,x,Z,T1,x1);
In the above sizes of T,x,Z should be same but they are no tin your case; so the error.
Réponses (2)
KL
le 11 Mai 2017
Modifié(e) : KL
le 11 Mai 2017
In your code,
z1=interp2(T,x,Z,T1,x1);
T and x must be of the same size and similarly T1 und x1. Z must be a matrix containing length(x) rows and length(T) columns.
whos T x Z T1 x1
Name Size Bytes Class Attributes
T 1x1000 8000 double
T1 1x100 800 double
Z 1x101000 808000 double
x 1x101 808 double
x1 1x100 800 double
2 commentaires
Voir également
Catégories
En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!