Help saving a vector to the workspace that is output from a function.

Hello. I currently have the function shown below:
function [numout, outvec]= SCAN_DATAmgl(vectin, lowlim, uplim)
%Compares each element of vectin against lowlim and uplim and returns
%a count (numout) of how many vector elements are greater than or less than the
%limits and a vector (outvec) of the actual out-of-limit readings
numout = 0;
for k = 1:length(vectin);
if vectin(k)>lowlim && vectin(k)<uplim;
numout = numout + 1;
outvec(numout) = vectin(k);
end
end
The function outputs the vector 'outvec' but it does not save it to the workspace. I need it in the workspace so that after I call the function in an m-file, I can display the vector. How do I do this?

Respuestas (1)

How are you calling the function? To get the variables in the workspace make sure you are capturing two outputs. E.g., call it like this:
[numout, outvec] = SCAN_DATA(vectin, lowlim, uplim);

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Preguntada:

el 24 de Feb. de 2015

Respondida:

el 24 de Feb. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by