Dialog Box to Matrix
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have to write a programme where I ask the user for certain values and use that values to test whether it fails or not. I want to convert the user entries (which is a cell array) into a matrix. How do I do that? My code looks as follows:
%Message box to explain to user what to do
message = sprintf('Hello! \n\n You are about to test the failure of a material. \n\n Please take note of the following: \n\n1. When asked to enter properties of material, \ndo not write values in scientific notation. \n\n2. Use a comma for decimal values. \n\n3. For unknown values, enter 0. \n\nClick OK to continue.'); %notes to be printed by message box
uiwait(msgbox(message, 'TAKE NOTE!','warn', 'modal')); %block execution that waits for user to response to message box before continiuing with the rest of the code
%Dialog box to gather user input of all material properties
%Dialog box split into two boxes to fit all questions
mat_prop_1 = inputdlg({'1. Material name:','2. Stress in x-direction [MPa]:', '3. Stress in y-direction [MPa]:', '4. Shear stress [MPa]:', ...
'5. Strain in x-direction [µm/m]:', '6. Strain in y-direction [µm/m]:', '7. Shear strain [µm/m]:', '8. Ply angle from positive x-direction [degrees]:', ...
'9. Longitudinal elastic modulus [GPa]:', '10. Transverse elastic modulus [GPa]:'}, 'Material Properties'); %first part of properties to be entered by user by means of dialog box
mat_prop_2 = inputdlg({'11. Major Poisson ratio:', '12. Shear Modulus [GPa]:', '13. Ultimate longitudinal tensile strength [MPa]:', ...
'14. Ultimate longitudinal compressive strength [MPa]:', '15. Ultimate transverse tensile strength [MPa]:', '16. Ultimate transverse compressive strength [MPa]:', ...
'17. Ultimate in-plane shear strength [MPa]:', '18. Safety Factor:'}, 'Material Properties'); %second part of properties to be entered by user by means of dialog box
I had to make two dialog boxes since all the questions did not fit into one.
1 Kommentar
Walter Roberson
am 8 Mai 2020
Bearbeitet: Walter Roberson
am 8 Mai 2020
cellfun(@str2double, mat_prop_1(2:end))
And make sure you check whether you get any nan results -- if you do then what was entered is not valid numbers.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Stress and Strain finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!