This code produces a NaN in the last column at the last position, Why?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
clear
clc
theta = 30;
vel0 = 25;
y0 = 2;
g = 9.81; %m/s^2
vel0x=vel0*cosd(theta);
vel0y=vel0*sind(theta);
d=((vel0*cosd(theta))/g)*(vel0*sind(theta)+sqrt((vel0*sind(theta))^2+2*g*y0));
x=linspace(0,d,50);
y=x.*tand(theta)-.5.*((g.*(x.^2))/((vel0.*cosd(theta))^2))+y0;
vely=(((vel0.*sind(theta)).^2)-2.*g.*y);
v=sqrt(vel0x.^2+vely.^2);
matrix=[x; y; v];
fid=fopen('ProjectileKinematics.dat','w')
fprintf(fid, '%f %f %f\n',matrix)
1 commentaire
Réponses (1)
Akanksha Shrimal
le 27 Avr 2022
Hi,
It is my understanding that you are getting NaN in the last value of matrix.
I do not get any NaN value in matrix. Let me know if you have any other queries.
It is a good practice to close all open files. You can use the below code to close the file.
fclose(fid);
0 commentaires
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices 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!