Question

In matlab how do I Prompt the user to select a material from the Material string...

In matlab how do I Prompt the user to select a material from the Material string array. If user exits out of the menu, keep asking the user for a selection until one is made. You will use this selection to determine the Young's modulus value from the Elasticity vector. Each material has a corresponding Young's modulus [Pa].

material=["Rubber","Wood (along grain)","Aluminum","Titanium","Graphene","Steel","Cobalt-Chrome"]

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%you can ask user to enter a number corresponding to the material
material=["Rubber","Wood (along grain)","Aluminum","Titanium","Graphene","Steel","Cobalt-Chrome"];
menu=sprintf('%s: %s\n',[string(1:length(material));material]);
fprintf(menu)
num = input('Enter a material: ');
while num<1 || num>length(material)
fprintf(menu)
num = input('Enter a material: ');%keep asking untill the correct choice is made
end
%in this way you can have the required index for young's modulus vector as
%well

Add a comment
Know the answer?
Add Answer to:
In matlab how do I Prompt the user to select a material from the Material string...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT