how to store 3 outputs of simulation in array and each time i run the simulation the outputs are stored in a the next row in the same array

2 次查看(过去 30 天)
s=[w1 w2 w3]

采纳的回答

Image Analyst
Image Analyst 2022-5-1
Try this:
numRuns = 10000; % How many times you want to run the simulation
allResults = zeros(numRuns, 3); % Array to hold all the results of all runs.
for k = 1 : numRuns
% Run your simulation and get results.
[w1, w2, w3] = MySimultationFunction();
% Tack on the results for this run to our master results list of all runs.
allResults(k, :) = [w1, w2, w3];
end
  3 个评论
Image Analyst
Image Analyst 2022-5-1
I think you need the function
function [w1, w2, w3] = MySimulationFunction()
%Energy wavelets
%first number is phase number @ second number is level of decomposition
%Ea energy wavelet approximate
%Ed energy wavelet detailed
%level 1
[Ea11,Ed11] = wenergy(cA1,LA1);
[Ea21,Ed21] = wenergy(cB1,LB1);
[Ea31,Ed31] = wenergy(cC1,LC1);
[Ea1,Ed1] = wenergy(cG1,LG1);
%level 2
[Ea12,Ed12] = wenergy(cA2,LA2);
[Ea22,Ed22] = wenergy(cB2,LB2);
[Ea32,Ed32] = wenergy(cC2,LC2);
%level 3
[Ea13,Ed13] = wenergy(cA3,LA3);
[Ea23,Ed23] = wenergy(cB3,LB3);
[Ea33,Ed33] = wenergy(cC3,LC3);
w1=sum(Ed11(1,:))+sum(Ed21(1,:))+sum(Ed31(1,:));
w2=sum(Ed12(1,:))+sum(Ed22(1,:))+sum(Ed32(1,:));
w3=sum(Ed13(1,:))+sum(Ed23(1,:))+sum(Ed33(1,:));

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Discrete Multiresolution Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by