Save multiple functions on a single vector
Afficher commentaires plus anciens
I have a function with 3 outputs
[out1,out2,out3=myfunction(dataset); (every output is a single number , it is the min avg and maximum value of the dataset)
I need to use a loop, so I will have out1,out2,out3 for every day and I want to save them in a matrix,I want every row to be a vector with the 3 outputs
Any suggestions?
5 commentaires
Guillaume
le 25 Fév 2020
How is every day defined? Is the day a variable of the dataset?
kounoupaki87
le 25 Fév 2020
kounoupaki87
le 25 Fév 2020
Guillaume
le 25 Fév 2020
What version are you on that you're still using nanmean, nanmax, nanmin?
Despite your statement, yout minmaxavg function doesn't return scalar outputs, but vectors. Note that the function can be greatly simplified but we'll worry about that once I've understood what it is you want.
I'm still unclear what it is you want. How is a day defined? Is each page of the matrix, a day, an hour, something else? Maybe another array defined what a page corresponds to. Also, do the rows and columns have any meaning, your current code takes the min/max/mean of all the elements, so it doesn't appear that the row/column separation is important.
kounoupaki87
le 25 Fév 2020
Réponse acceptée
Plus de réponses (1)
Jesus Sanchez
le 25 Fév 2020
One possibility is to work with them as vectors and then unite them in one matrix.
everyDay = 10; % N
out1 = zeros(everyDay,1); % Size Nx1
out2 = zeros(everyDay,1);
out3 = zeros(everyDay,1);
for n=1:everyDay
[out1(n),out2(n),out3(n)]=myfunction(dataset);
end
savedData = [out1(n),out2(n),out3(n)];
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!