Why does my code only come out with one result?
조회 수: 2 (최근 30일)
이전 댓글 표시
function [siftedData, siftedMean, siftedStd, siftedNorm] = project2(rawData, categories, selectedCategory)
rawData(categories == selectedCategory) = [];
siftedData = rawData;
siftedMean = mean(rawData);
siftedStd = std(rawData)
siftedNorm = (rawData - siftedMean) ./ siftedStd;
%call with project2([1.2, 3.4, 7.6, 8.4], [1, 0, 0, 1], 1)
end
I'm supposed to have 4 outputs but when I call the function I only get the result of siftedData. Even if I use siftedData or rawData in the equations I still only get one answer.
댓글 수: 0
채택된 답변
Star Strider
2020년 10월 21일
Call it as:
[siftedData, siftedMean, siftedStd, siftedNorm] = project2(rawData, categories, selectedCategory)
and all the outputs will appear in your workspace. The default behaviour for functions with several outputs is to only return the first output if there is only one assignment. If you want all of them, you need to ask for all of them.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!