Issue with the number of outputs in my function

2 次查看(过去 30 天)
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!

采纳的回答

Star Strider
Star Strider 2018-2-9
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);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by