필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Newbie question - capturing mutliple return from a function into an array

조회 수: 1 (최근 30일)
matal
matal 2011년 7월 8일
마감: MATLAB Answer Bot 2021년 8월 20일
A function f() returns 2 numbers. So, I typically call it like this:
[x,y] = f(<inputs>)
Now I want to multiply the outputs of f by 100. Looks like I need 5 lines to do this:
[x,y] = f(<inputs>); temp = [x,y]; temp = temp * 100; x = temp(1); y = temp(2);
This is because [x,y] = 100 * f(<inputs>) doesn't work. Nor does [x,y] = 100 * [x,y];
This seems awkward.
My current workaround has been to wrap f() into another function f_array() that returns the outputs as an array. Any other more elegannt solution?t solution?

답변 (1개)

the cyclist
the cyclist 2011년 7월 8일
At the very least, you can skip the temp step, and just directly do
[x,y] = f(<inputs>);
x = 100*x;
y = 100*y;

이 질문은 마감되었습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by