Position and extraction of row

4 ビュー (過去 30 日間)
Alexandra Philip
Alexandra Philip 2020 年 7 月 1 日
コメント済み: Star Strider 2020 年 7 月 2 日
I am having some trouble find the position of the row within a table. I first did:
[rows,columns]=find(strcmp(mergetable1{:,1},AccelSN),1) to try to find where the user input variable(AccelSN) matches a number in the 1st column and then to find the row where the values match.
I use BIA0=mergetable1{rows,2} to extract the value in the same row extracted in the previous line and in the 2nd column.
I get an output of:
rows =
[]
and
BIA0 =
0×1 empty double column vector
Any suggestions to obtain the row and get an extracted value from the column of that row?

採用された回答

Star Strider
Star Strider 2020 年 7 月 1 日
It would definitely help to see what ‘mergetable1’ is, and how you are getting ‘AccelSN’.
If ‘AccelSN’ is read as a string (for example from inputdlg), use the str2double function to get it as a number, since the first column of ‘mergetable1’ is apparently numeric.
For example:
mergetable1 = array2table(randi(9, 10, 3)) % Create Table (To Test Code)
AccelSN = {'4'}; % From ‘inputdlg’
AccelSN = str2double(AccelSN); % Convert To Numeric
BIA0 = mergetable1{AccelSN == mergetable1{:,1},2}
Col_3 = mergetable1{AccelSN == mergetable1{:,1},3}
Please test that with your table and code, since I cannot.
.
  3 件のコメント
Alexandra Philip
Alexandra Philip 2020 年 7 月 1 日
I was able to get the code to work. Thank you.
Star Strider
Star Strider 2020 年 7 月 2 日
As always, my pleasure!
(It would have helped significantly to have your table and code.)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by