필터 지우기
필터 지우기

Issue with the number of outputs in my function

조회 수: 2 (최근 30일)
Rich Cavanaugh
Rich Cavanaugh 2018년 2월 9일
댓글: Star Strider 2018년 2월 9일
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);
  댓글 수: 2
Rich Cavanaugh
Rich Cavanaugh 2018년 2월 9일
yup that works! Thank You so much.
Star Strider
Star Strider 2018년 2월 9일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (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