How do i evaluate a matrix in row by row case?

2 ビュー (過去 30 日間)
HabenG
HabenG 2021 年 12 月 10 日
編集済み: HabenG 2021 年 12 月 10 日
The data set contains values that fall within the two if statemet ranges. What i would like to do is that, execute each value separatetly. so for example if a value in row 3 column 1 falls within the first if statemet range then that gets executed and if the value in row 4 column 1 falls in the second if statemnt range that also gets executed. essentially i want to look at the data in a row by row case and keep the values in separate tables for each columns.
If there is another way of doing this please share.
Testdata;
n = 0;
Dist_type = {'Kernel', 'Gamma', 'Normal','Weibull'};
for j = 1 : numel(Dist_type)
if Testdata(Testdata(:,j) > 11.23 & Testdata(:,j) < 11.19) & (n == ~ 1)
%.....
n = 1;
t1 = table(Testdata(Testdata(:,j) > 11.23 & Testdata(:,j) < 11.19))
elseif Testdata(Testdata(:,j) > 11.28 & Testdata(:,j) < 11.33) & (n == ~ -1)
% .......
n = -1;
t2 = table(Testdata(Testdata(:,j) > 11.28 & Testdata(:,j) < 11.33))
else
n = 0;
end
end

採用された回答

Voss
Voss 2021 年 12 月 10 日
編集済み: Voss 2021 年 12 月 10 日
Maybe something like this is what you want:
Dist_type = {'Kernel', 'Gamma', 'Normal','Weibull'};
for j = 1 : numel(Dist_type)
% Make two tables of the values in the jth column of Testdata that are
% within the two ranges:
% (Note that the first range as initially written would always contain
% no data, so I switched it around.)
t1 = table(Testdata(Testdata(:,j) > 11.19 & Testdata(:,j) < 11.23,j));
t2 = table(Testdata(Testdata(:,j) > 11.28 & Testdata(:,j) < 11.33,j));
% Do something with the tables
end
If you really want to go row-by-row, you can do that by adding a second nested for loop, but the code was already essentially operating on all rows at once.
  1 件のコメント
HabenG
HabenG 2021 年 12 月 10 日
編集済み: HabenG 2021 年 12 月 10 日
I will try this and yes i really need to go row by row beause this is supposed to operate on a streaming data so i wont have a table or a set of data. The only other option i have is to make this work based on the last value that falls within any of those two statement....also thanks much

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by