필터 지우기
필터 지우기

My matlab function is only returning one output

조회 수: 7 (최근 30일)
Anita Osoh
Anita Osoh 2020년 10월 14일
댓글: Anita Osoh 2020년 10월 14일
function [ sd, mea, mod, va, med ] = StatisticsHw(x)
sd = range(x, 'all');
mea = mean(x);
mod = mode(x);
va = var(x);
med = median(x);
end

답변 (1개)

KSSV
KSSV 2020년 10월 14일
You have to define your input and call the function in the workspace as shown below.
x = rand(1,100) ;
[ sd, mea, mod, va, med ] = StatisticsHw(x) ;
sd
mea
mod
va
med
  댓글 수: 4
KSSV
KSSV 2020년 10월 14일
First save the function in a file with name StatisticsHw.m in some folder. Go to the respective folder...this should be your current working folder. Then try
x = [3 3 3 4 4 4 5 5 5 5 6 8] ;
[sd, mea, mod, va, med ] = StatisticsHw(x) ;
Anita Osoh
Anita Osoh 2020년 10월 14일
thanks it finally worked when i called the function like
[ va, mea, mod, med, sd ]= StatisticsHw(x)

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

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by