Converting 2D matrix to 3D
Show older comments
for alpha = 1:90
v0 = 200;
g=9.81;
y0(1) = 0;
y0(2) = v0*sind(alpha);
y0(3) = 0;
y0(4) = v0*cosd(alpha);
tspan = 1:0.5:700;
options = odeset('Events','event_proj');
[t,y] = ode45(@proj, tspan, y0,options);
a_m(:,:,alpha) = y;
end
(Basic projectile motion equation.) I'm trying to save y-state matrix to a_m 3D-matrix. When program calculates the y values for different alphas, It will store the y matrix into 3D matris whose third dimension is same as alpha. When I try to run the code above, I get
Subscripted assignment dimension mismatch.
Error in deneme1 (line 16)
a_m(:,:,alpha) = y;
I try to assign y to another variable(say, y_d), but it gave the same error. Any thoughts? It is supposed to be very easy but I can't figure it out.
Thank you.
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!