0

I'm quite new to matlab so this might be a very simple question but I can't seem to get my head around it, so would really appreciate any help!

I have this function, which is supposed to create a new variable 'retrievalList' which is a cell composed of the raw contents of an excel spreadsheet:

function [retrievalList] = dispList( pID );

switch pID;
case pID < 5;
  [num txt raw] = xlsread('list00.xlsx');
  retrievalList = (raw);
    case pID(pID >= 5 && pID < 9);
    [num txt raw] = xlsread('list01.xlsx');
    retrievalList = (raw);;
end
end

For some reason the output of this function is a general 'ans' instead of 'retrievalList', can anyone explain what I'm doing wrong?

Many thanks, Darya

D. Frank
  • 1
  • 1
  • 5
    What's used in the function is arbitrary. You need to call the function with the assignment, e.g. `retrievalList = dispList(pID);` – Steve Apr 03 '16 at 16:21
  • 2
    See [Call Functions](http://uk.mathworks.com/help/matlab/matlab_prog/call-a-function.html) – Steve Apr 03 '16 at 16:30

0 Answers0