Effacer les filtres
Effacer les filtres

Issue with the number of outputs in my function

2 vues (au cours des 30 derniers jours)
Rich Cavanaugh
Rich Cavanaugh le 9 Fév 2018
Commenté : Star Strider le 9 Fév 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!

Réponse acceptée

Star Strider
Star Strider le 9 Fév 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 commentaires
Rich Cavanaugh
Rich Cavanaugh le 9 Fév 2018
yup that works! Thank You so much.
Star Strider
Star Strider le 9 Fév 2018
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by