I'm trying to write a simple function that takes two inputs, x and y, and passes these to three other simple functions that add, multiply, and divide them. The main function should then display the results as a string containing x, y, and the totals.
我試着寫一個簡單的函數,它接受兩個輸入,x和y,然后把它們傳遞給另外三個簡單的函數,它們相加,相乘,然后除以它們。主函數應該將結果顯示為包含x、y和總數的字符串。
I think there's something I'm not understanding about output arguments. Anyway, here's my (pitiful) code:
我認為有些東西我不理解輸出參數。不管怎樣,這是我的(可憐的)代碼:
function a=addxy(x,y)
a=x+y;
function b=mxy(x,y)
b=x*y;
function c=dxy(x,y)
c=x/y;
The main function is:
主要功能是:
function [d e f]=answer(x,y)
d=addxy(x,y);
e=mxy(x,y);
f=dxy(x,y);
z=[d e f]
How do I get the values for x, y, d,