Borrar filtros
Borrar filtros

Issue with the number of outputs in my function

2 visualizaciones (últimos 30 días)
Rich Cavanaugh
Rich Cavanaugh el 9 de Feb. de 2018
Comentada: Star Strider el 9 de Feb. de 2018
Hi, total MATLAB novice here. I am writing a program for class and I am having an issue with the number of outputs the program gives me after I run.
function [mean, median, variance] = createData(dataInput)
dataSet=[]; %establishes the existance of dataSet
updatedDataSet = addData(dataSet,dataInput); %calls to addData function to put the new input into the dataset
dataSet=updatedDataSet; %updates the value of dataSet
mean = meanCalculator(updatedDataSet); %calls the mean calculator to find mean
median = medianCalculator(updatedDataSet); %calls the median calculator to find median
variance = varianceCalculator(updatedDataSet,mean); %calls varianceCalculator to find variance
end
All the individual calculators work by themselves, and feed the outputs to this central program, but the program will only release the value for the "mean" variable once it is finished. I am not sure why it is doing this... Can anyone help? Thanks in advance!

Respuesta aceptada

Star Strider
Star Strider el 9 de Feb. de 2018
The default behaviour for function output is to return only the first output unless you ask for all of them.
This will return all three:
dataInput = ...;
[mean, median, variance] = createData(dataInput);
  2 comentarios
Rich Cavanaugh
Rich Cavanaugh el 9 de Feb. de 2018
yup that works! Thank You so much.
Star Strider
Star Strider el 9 de Feb. de 2018
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical 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