Making a statistics function output a matrix

1 vue (au cours des 30 derniers jours)
Michael Valent
Michael Valent le 14 Oct 2020
Modifié(e) : Ameer Hamza le 14 Oct 2020
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!

Réponses (1)

Ameer Hamza
Ameer Hamza le 14 Oct 2020
Modifié(e) : Ameer Hamza le 14 Oct 2020
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:

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by