Azzera filtri
Azzera filtri

Why does my code only come out with one result?

2 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Star Strider
Star Strider il 21 Ott 2020
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.

Più risposte (0)

Categorie

Scopri di più su Multidimensional Arrays in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by