Making a statistics function output a matrix

조회 수: 1 (최근 30일)
Michael Valent
Michael Valent 2020년 10월 14일
편집: Ameer Hamza 2020년 10월 14일
I have a function that calculates the skewness and kurtosis ratios simultaneously with two outputs, [skewness, kurtosis]
Essentially, I want to compare multiple outputs in a big matrix, with each line or column being a different skewness/kurtosis ratio
I've reviewed ( this answer ) but I didn't find what I needed.
As completely embarassing as this is, this is what I am trying to do:
function [m] = matrix(a,b, c)
%ratios calculates skewness and kurtosis ratios
[sk ku] = ratios(y.a);
[sk2 ku2] = ratios(y.b);
[sk3 ku3] = ratios(y.c);
% m is the theoretical output matrix that included the ratios for all inputs
m = [sk ku; sk2 ku2; sk3 ku3];
end
Thank you in advance!

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 10월 14일
편집: Ameer Hamza 2020년 10월 14일
It depends on the dimensions of the output vectors. If they all have equal lengths, then your approach is correct. However, If they have different lengths, then you will need to use cell arrays
function [m] = matrix(a,b, c)
%ratios calculates skewness and kurtosis ratios
[sk ku] = ratios(y.a);
[sk2 ku2] = ratios(y.b);
[sk3 ku3] = ratios(y.c);
% m is the theoretical output matrix that included the ratios for all inputs
m = {sk ku; sk2 ku2; sk3 ku3};
end
Read about cell arrays:

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by