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

3 ビュー (過去 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 Center および File ExchangeSignal Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by