Numbering table and selecting value

Hi,
This is a section of my program where I display the top 5 values for steel sections (from a manually inputted list of values), and then gives an options to select one of the sections to move on to further calculations.
How can I create the table to list the options 1-5, and then use the disp function to input a 1-5 number which will select the corresponding value?
Also, I have tried using the disp function and just typing in the full section but for some reason it gives a different Resistance value to the corresponding section in the list. Any thoughts?
Thanks,
Finlay
crossSectionInfo = sortrows( crossSectionInfo, 'Resistance' );
bestCrossSectionIndex = find( crossSectionInfo.Resistance > Mr, 5, 'first'); % five sections with suitable Mp resistance
disp( crossSectionInfo(bestCrossSectionIndex,:) )
result = input('Which steel section would you like to select?:','s');
disp( 'Value is');
disp(crossSectionInfo.Resistance(Name==result));

回答 (1 件)

madhan ravi
madhan ravi 2020 年 2 月 23 日
編集済み: madhan ravi 2020 年 2 月 23 日

0 投票

Try replacing
Name==result
with
strcmp(crossSectionInfo.Name,result)

3 件のコメント

Finlay Brierton
Finlay Brierton 2020 年 2 月 24 日
Hi Madhan, that worked thank you.
Do you have a suggestion for the first part of my question:
"How can I create the table to list the options 1-5, and then use the disp function to input a 1-5 number which will select the corresponding value?"
Thanks
madhan ravi
madhan ravi 2020 年 2 月 24 日
Maybe you are looking for uitable()
Finlay Brierton
Finlay Brierton 2020 年 2 月 24 日
I just want to list the five options as numbered 1-5 in the first column, but cannot find anything to do this

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2020 年 2 月 23 日

コメント済み:

2020 年 2 月 24 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by