Error using * Inner matrix dimensions must agree - using meshplot
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have been trying to draw the direction fields of some first order differential equations and sometimes I can get it to work, others not.
This is an example of a problem I have just had:
To sketch the direction field of dy/dt - 2*y = t^2 . e^(2t)
I have tried the following:
>> [t y]=meshgrid(0:0.5:2,-4:0.5:4); >> dy=t.^2*exp(2.*t)+2.*y;
But an it immediately states there is an error: Error using * Inner matrix dimensions must agree.
I can't see what the problem is because in other instances this error does not occur. For example, this worked perfectly:
>> [t y]=meshgrid(-4:0.5:4,-4:0.5:4); >> dy=t - 3*y +exp(-2*t); >> dt=ones(size(dy)); >> L=sqrt(1+dy.^2); >> quiver (t, y, dt./L, dy./L, 0.5), axis tight;
0 Kommentare
Akzeptierte Antwort
Mischa Kim
am 4 Mär. 2014
Bearbeitet: Mischa Kim
am 4 Mär. 2014
Will, use
[t y] = meshgrid(0:0.5:2,-4:0.5:4);
dy = t.^2.*exp(2*t) + 2.*y; % need to use dot operators all the way
dt = ones(size(dy));
L = sqrt(1 + dy.^2);
quiver (t, y, dt./L, dy./L, 0.5)
axis tight;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!