Why is the function not outputting all the variable?

function [C, out1, out2] = test()
yes = true;
no = false;
logic = yes;
c = 0;
while logic == yes
c = c + 1;
k = input('input 1st value ');
j = input('input 2nd value ');
A(c) = k;
B(c) = j;
C(c) = 2*k-j;
logic = input('would you like to continue ');
end
fprintf('Value of A,B, and C are respectively');
for i = c:-1:1
numerize(i) = 10^(i-1);
end
out1 = sum(numerize.*A);
out2 = sum(numerize.*B);
C = sum(numerize.*C);
end
The following code only outputs C for some reason. What's wrong with it? I have out1 and out2 and when I debug it shows me that they are calculated.

2 件のコメント

Walter Roberson
Walter Roberson 2012 年 1 月 29 日
Please show the command you use to invoke test()
Yaman
Yaman 2012 年 1 月 29 日
test()

サインインしてコメントする。

回答 (1 件)

Andreas Goser
Andreas Goser 2012 年 1 月 29 日

2 投票

You need to call your function in a way that it stores the to be returned values in variables like
[notnecessarilyC, xyzout1, abcout2] = test()

1 件のコメント

Yaman
Yaman 2012 年 1 月 29 日
thanks. I just realized that.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeModify Image Colors についてさらに検索

質問済み:

2012 年 1 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by