Filter löschen
Filter löschen

Issue with the number of outputs in my function

2 Ansichten (letzte 30 Tage)
Rich Cavanaugh
Rich Cavanaugh am 9 Feb. 2018
Kommentiert: Star Strider am 9 Feb. 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!

Akzeptierte Antwort

Star Strider
Star Strider am 9 Feb. 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 Kommentare
Rich Cavanaugh
Rich Cavanaugh am 9 Feb. 2018
yup that works! Thank You so much.
Star Strider
Star Strider am 9 Feb. 2018
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by