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

2 vues (au cours des 30 derniers jours)
HabenG
HabenG le 10 Déc 2021
Modifié(e) : HabenG le 10 Déc 2021
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

Réponse acceptée

Voss
Voss le 10 Déc 2021
Modifié(e) : Voss le 10 Déc 2021
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 commentaire
HabenG
HabenG le 10 Déc 2021
Modifié(e) : HabenG le 10 Déc 2021
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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by