Borrar filtros
Borrar filtros

Why does my code only come out with one result?

2 visualizaciones (últimos 30 días)
Kylenino Espinas
Kylenino Espinas el 21 de Oct. de 2020
Respondida: Star Strider el 21 de Oct. de 2020
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.

Respuesta aceptada

Star Strider
Star Strider el 21 de Oct. de 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.

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by