MATLAB: Displaying the output of a function as a column vector

MATLABmatrixoutput

Hi,
I have two codes. One with a base function code and another one which calls that function with a set of values for its inputs. Now 4 out of 5 parameters will have fixed values and the 5th parameter "wr" will be from 0 to 1 inclusive. Our code is able to generate a column vector for wr but not for the associated values of U. Using a For Loop in the calling script, I was able to output the values for U in the command window but I want them to be stored as an Nx2 matrix with column 1 giving values for wr and column 2 giving values for U. I have not shared the For Loop code here.
Base function:
<Start>
function Assignment = Function(Rf,Erp,Sigp,RAF,wr)
Rf >= 0;
Erp > Rf;
Sigp > 0;
RAF >= 1;
(wr>=0) && (wr<=1);
U = Rf + (Erp-Rf)*wr - RAF*(wr^2)*(Sigp^2)/2;
Assignment = U;
<End>
Function which calls the above function:
<Start>
Rf = 0.02;
Erp = 0.06;
Sigp = 0.2;
RAF = 1.5;
wr = [0:0.1:1]';
try
Assignment = Function(Rf,Erp,Sigp,RAF,wr);
end
<End>

Best Answer

Rf = 0.02;
Erp = 0.06;
Sigp = 0.2;
RAF = 1.5;
wr = [0:0.1:1]';
try
Assignment = Function(Rf,Erp,Sigp,RAF,wr);
Assignment
catch ME
fprintf('Failed Function\n');
end
Assignment = 11×1
0.0200 0.0237 0.0268 0.0293 0.0312 0.0325 0.0332 0.0333 0.0328 0.0317
function Assignment = Function(Rf,Erp,Sigp,RAF,wr)
Rf >= 0;
Erp > Rf;
Sigp > 0;
RAF >= 1;
(wr>=0) & (wr<=1);
U = Rf + (Erp-Rf).*wr - RAF.*(wr.^2).*(Sigp.^2)/2;
Assignment = U;
end