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?
답변 (1개)
James Tursa
2015년 2월 24일
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);
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!