How to get a certain value based on the maximum of another value?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello everyone!
Out of a Struct I want to get a certain value based on the maximum of the maximum of another value. I know it is possible with the max() function which gives me the index of the maximum value. But I can't really combine the information with the other value.
For example I want to get the maximum of "vfzg_w" and the connected value of "tmot" - and all that integrated in an Interval and for loop.
Below is an extract of my code so far. The idea is to just append it with the same structure to the Struct "Statistik", but I don't know if that is possible.
Maybe someone has an idea :)
for new_idx_loopi = 1 : length (MasterStruct.MDF_FileList_fil)
index_10ms =strfind({MasterStruct.Struct_RAW_Rasters.RasterName},{'10ms'});
Index_100_Hertz_Raster=find(not(cellfun('isempty',index_10ms)));
Struct_Import_temp = mdf_import(MasterStruct.MDF_FileList_fil{new_idx_loopi},{MasterStruct.Struct_RAW(new_idx_loopi).Channels(MasterStruct.IDX_CHANNEL).UniqueName}, 'raster', MasterStruct.Struct_RAW_Rasters(Index_100_Hertz_Raster).RasterName);
Struct_Import(new_idx_loopi).Channels =Struct_Import_temp.Channels;
Struct_Import(new_idx_loopi).Rasters =Struct_Import_temp.Rasters;
Struct_Import(new_idx_loopi).Meta = MasterStruct.MDF_FileList_fil(new_idx_loopi);
CHANNEL = Struct_Import(new_idx_loopi).Channels;
sortiert_idx = sort(lower({CHANNEL.DisplayName}'));
[NuVar sortiert_idx]=sort(lower({CHANNEL.DisplayName}'));
sortiert_C = CHANNEL(sortiert_idx);
Geschwindigkeit_Struct = sortiert_C(11);
Temperatur_Struct = sortiert_C(9);
%---------------------------------------------------------------------------------------------------------------------------
switch MasterStruct.B_IntervallTyp
case 'Zeitintervall'
Time_Axis=Struct_Import(new_idx_loopi).Rasters(1).Data;
Interval_Startzeit=Time_Axis(1);
idxStart=1;
SplitCounter=1;
for time_run =1:size(Time_Axis,1)
Aktuelle_Differenz_Time=Time_Axis(time_run)-Interval_Startzeit;
if Aktuelle_Differenz_Time >= MasterStruct.INTERVAL_VALUE_TIME
Interval_Startzeit=Time_Axis(time_run);
idx_mean = find(strcmp({MasterStruct.Channel_Liste{:,2}} , 'x'));
idx_max = find(strcmp({MasterStruct.Channel_Liste{:,3}} , 'x'));
idx_min = find(strcmp({MasterStruct.Channel_Liste{:,4}}, 'x'));
idx_crit =find(strcmp({MasterStruct.Channel_Liste{:,1}}, 'tmot'));
Kanalliste_mean = {MasterStruct.Channel_Liste{idx_mean}};
Kanalliste_max = {MasterStruct.Channel_Liste{idx_max}};
Kanalliste_min = {MasterStruct.Channel_Liste{idx_min}};
Kanalliste_crit = {MasterStruct.Channel_Liste{idx_crit}};
for pow = 1:size(Kanalliste_mean,2)
Statistik(new_idx_loopi).Mean(SplitCounter,pow) = mean(sortiert_C(idx_mean(pow)).Data(idxStart:time_run));
end
for bam = 1:size(Kanalliste_max,2)
Statistik(new_idx_loopi).Max(SplitCounter,bam) = max(sortiert_C(idx_max(bam)).Data(idxStart:time_run));
end
for bang = 1:size(Kanalliste_min,2)
Statistik(new_idx_loopi).Min(SplitCounter,bang) = min(sortiert_C(idx_min(bang)).Data(idxStart:time_run));
end
idxStart=time_run;
SplitCounter=SplitCounter+1;
end
end
end
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!