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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by