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

조회 수: 1 (최근 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