Help saving a vector to the workspace that is output from a function.
Ältere Kommentare anzeigen
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?
Antworten (1)
James Tursa
am 24 Feb. 2015
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);
Kategorien
Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!