how to write a for loop for 4 screws which have x,y,z so that it get print

3 vues (au cours des 30 derniers jours)
PA le 4 Juil 2022
Commenté : PA le 5 Juil 2022
  1 commentaire
Garmit Pant
Garmit Pant le 4 Juil 2022
Can you please elaborate your question?

Connectez-vous pour commenter.

Réponses (1)

Garmit Pant
Garmit Pant le 4 Juil 2022
Hello Anwesha
You can use the following code snippet to write the data that you have provided into a text file.
x = [77,-60,-1.11; 120,-60,-1.11 ; 130,-60,-1.11; 140,60,-1.11];
fileID = fopen('exp.txt','w');
for i = 1:size(x,1)
fprintf(fileID, 'SCREW;X;%4.2f\n',x(i,1));
fprintf(fileID, 'SCREW;Y;%4.2f\n',x(i,2));
fprintf(fileID, 'SCREW;Z;%4.2f\n',x(i,3));
You can read more about 'fprintf' to understand how text can be written into text files:
  8 commentaires

Connectez-vous pour commenter.


En savoir plus sur Loops and Conditional Statements 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!

Translated by