Author Topic: need matrix as output of if loop  (Read 401 times)

Offline tomgreen

  • Newbie
  • *
  • Posts: 1
  • Matlab Forum
    • View Profile
need matrix as output of if loop
« on: July 25, 2011, 08:59:40 AM »
 hi
i need a matrix as the result of a loop of an if function on a matrix:
i placed the loop in a function so as to call it from the command window or a script. the function looks like this:
function [IbyT] = IbyT (LF)
i=1;
while i<=numel(LF);
    if(1/(1-LF(i))<2.5)
    IbyT=1/(1-LF(i));
else
    IbyT=2.5;
    end
    disp(IbyT);
    i=i+1;
end

LF is a 6x1 matrix with the following values:
    0.9641
    0.4025
    0.2526
    0.1800
    0.1361
    0.1064

if i run IbyT(LF) in the command window the IbyT values are nicely displayed in a row, followed by ans =  1.1191 (the last value). i need these displayed values to be a matrix so that i can continue to work with it. how do i let hte output (IbyT) be a matrix?
thanks, tom.

Matlab and SimuLink Development Forum

need matrix as output of if loop
« on: July 25, 2011, 08:59:40 AM »