Hello, I am having trouble making a script that will show a table of values
Afficher commentaires plus anciens
The assignment states: Make a script that stores the data in force and distance vectors and computes the corresponding work values (no input and no screen echo). Use disp() to generate a table showing all the force, distance, and work values with appropriate labeling and units. Use appropriate format strings to get the numbers to line up. The data is as shown:
Segment: 1 2 3 4 5
-------------------------------------------
Force(N): 400 550 700 500 600
Distance(m): 3 0.5 0.75 1.5 5
Here is what I try but I always get an error:
Force = [400 550 700 500 600];
Distance = [3 0.5 0.75 1.5 5];
disp(' ')
disp(['Segment ',num2str(1:5,'%10i') ])
disp(['Force, N ',num2str(Force, '%10.0f') ])
disp(['Distance, m ',num2str(Distance, '%10.0f') ])
disp('Segment', num2str(1:5))
disp([ char(8*ones(2,5), num2str([Force;Distance]) ])
disp(' ')
2 commentaires
@Lizzy Murphy: this is not twitter, so I removed the unnecessary # from the tag. I also formatted your code correctly for you: in future you can do this simply by selecting the code text, the clicking the {} Code button, followed by an empty line.
"Here is what I try but I always get an error:"
What is the complete error message that you get?
Lizzy Murphy
le 28 Fév 2018
Modifié(e) : Lizzy Murphy
le 28 Fév 2018
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!