필터 지우기
필터 지우기

Numbering options in a table

조회 수: 2 (최근 30일)
Finlay Brierton
Finlay Brierton 2020년 2월 24일
답변: Steven Lord 2020년 2월 24일
Hi,
I am struggling to do the following. I have written a short program to select steel section sizes and included a screenshot below.
I would like to have a number for each row in the table I produce, so when entering the steel section option I wish to go with. It can be a number "1", instead of having to type in "457x152x67".
Thanks
  댓글 수: 1
Star Strider
Star Strider 2020년 2월 24일
... and included a screenshot ...
Copying the code itself and pasting it to your Question (or a Comment to it) and then using the leftmost button in the CODE section of the top toolstrip to format it would be preferable. I doubt that any versions of MATLAB can run screenshots of code, only the code itself.

댓글을 달려면 로그인하십시오.

답변 (2개)

Turlough Hughes
Turlough Hughes 2020년 2월 24일
You could change Line 58 to the following:
disp(crossSectionInfo.Resistance(str2double(result)))

Steven Lord
Steven Lord 2020년 2월 24일
This example uses the table created by the code in the help text for the table function.
Step 1: Build the original table.
load patients
patients = table(LastName,Gender,Age,Height,Weight,Smoker,Systolic,Diastolic);
Step 2: Add RowNames to each row. I'm assuming you're using a release that supports defining a string array using double-quotes.
patients.Properties.RowNames = "Row" + (1:height(patients)).';
Step 3: Display the results to show that each row has a name
head(patients)
Step 4: Use the row name
patients('Row4', :)
Of course, using the row number directly also works.
patients(4, :)

카테고리

Help CenterFile Exchange에서 MATLAB Code Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by