How to add a column to a table

3 ビュー (過去 30 日間)
Sean St Cyr
Sean St Cyr 2020 年 9 月 17 日
回答済み: Star Strider 2020 年 9 月 17 日
load ('StreamData.mat')
WL = Stream{:,2};
H = Stream{:,3};
V = Stream{:,4};
FlowRate = WL.*H.*V;
StreamSorted = sortrows(Stream,"FlowRate")
I am trying to take a 6x4 table called Stream from the .mat file and add my calculated value of FlowRate that is a 6x1 matrix and add this to my table with the title Flow Rate. I have tried multiplte things and it stil hasnt worked i get errors.
  2 件のコメント
VBBV
VBBV 2020 年 9 月 17 日
What errors do you get ? Could you show the text in red color ?
Sean St Cyr
Sean St Cyr 2020 年 9 月 17 日
Well, They are various errors i was trying with differnt coding, I had added
FlowRate = array2table(FlowRate);
since it was a matrix but im not sure how to add FlowRate to the Table Stream

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

回答 (1 件)

Star Strider
Star Strider 2020 年 9 月 17 日
Try this:
Stream = mat2cell(randi(9,6,4), 6, ones(1,4)); % Create Stream
WL = Stream{:,2};
H = Stream{:,3};
V = Stream{:,4};
FlowRate = WL.*H.*V;
[~,idx] = sort(FlowRate);
StreamTable = table(WL(idx,:),H(idx,:),V(idx,:),FlowRate(idx,:));
.

カテゴリ

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