Storing the output of a program in a matrix

조회 수: 1 (최근 30일)
Phillip Smith
Phillip Smith 2019년 12월 1일
답변: BobH 2020년 3월 5일
Hello,
I've made a program, doesn't matter what it does, and say it's called "progA". I get the program progA to output a number into the console everytime I run it. Now I want to make another program that runs progA and stores the output in a new array.
How would I go about this?
many thanks,
Phill

답변 (2개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 12월 1일
편집: KALYAN ACHARJYA 2019년 12월 1일
No need to run another program to save the output of progA in array. Just do the indexing in progA, its automatically generates the array of data.
It would be more clear, if you can share the represenative/skeleton code of progA
  댓글 수: 2
Phillip Smith
Phillip Smith 2019년 12월 1일
I want to run the progA a bunch of times and as the output will be different each time, I want to store each one in an array i.e it runs 473 times, I want an array of 473 outputs!
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 12월 1일
Then save 473 outputs arrays in a cell array

댓글을 달려면 로그인하십시오.


BobH
BobH 2020년 3월 5일
Do you mean like this?
progA = @() 42; % return 42 for each invocation
y = progA()
y =
42
z = arrayfun(@(X) progA(), 1:473);

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by