How do I get my variable to list in different columns of the ASCII file I am saving them to?
1 view (last 30 days)
Show older comments
When I run this script the variables all save to the same column, but I need them to be listed side by side. How do I get them to do this?
% Constants and initial conditions
theta = 30;
vel0 = 25;
y0 = 2;
g = 9.81; %m/s^2
d = ((vel0*cosd(theta))/g)*((vel0*sind(theta)) + sqrt((vel0*sind(theta))^2 + (2*g*y0)));
x = linspace(0, d, 50);
x = x';
for i=1:50
yT(i) = x(i) * tand(theta) - ((0.5) * ((x(i)^2 * g) / (vel0 * cosd(theta))^2)) + y0;
end
y = yT';
velX = vel0 * cosd(theta);
for i=1:50
velY = (vel0 * sind(theta))^2 - 2 * g * y(i);
velT(i) = sqrt(velX^2 + velY);
end
vel = velT';
final = [x, y, vel],
save('ProjectileKinematics.dat', 'x','y', 'vel', '-ascii')
0 Comments
Answers (1)
Voss
on 12 Nov 2022
final = [x, y, vel];
save('ProjectileKinematics.dat', 'final', '-ascii')
0 Comments
See Also
Categories
Find more on String Parsing 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!