필터 지우기
필터 지우기

How to store 4 outputs in 1 variable?

조회 수: 1 (최근 30일)
Sam
Sam 2018년 1월 25일
댓글: Stephen23 2018년 1월 25일
Hello,
I can't seem to find the solution for my problem. I created a function which gives 4 outputs. I call the function in the command window:
x = rand([50,1])
a([1,2,3,4])= descriptives(b)
descriptives gives the max,min,mean and std for a random vector. I want to store these 4 values into a vector, but I don't know how to do it...
Thanks

채택된 답변

Star Strider
Star Strider 2018년 1월 25일
Try this:
[a(1),a(2),a(3),a(4)] = descriptives(b)
This assumes ‘descriptives’ returns 4 separate scalar values.
  댓글 수: 1
Stephen23
Stephen23 2018년 1월 25일
More robust with preallocation:
a = zeros(1,4);
[a(1),a(2),a(3),a(4)] = descriptives(b)

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by