フィルターのクリア

How to make a three dimensional matrix

1 回表示 (過去 30 日間)
Wietze Zijpp
Wietze Zijpp 2022 年 4 月 6 日
回答済み: Dyuman Joshi 2022 年 4 月 7 日
Suppose I have the following
function [G,Tstat,P] = Fama_MacBeth(X,Y)
% Inputs:
% X is the matrix of explenatory variables of dimensions TxNxK, where T is
% the sample size, N is the number of assets, and k is the number of
% independent variables;
% Y is the matrix of excess returns of dimensions TxN;
Now I have my data Y of size T x N and X of size T x N.
I know that k = 3. However , how do I transform my matrix X such that it becomes T x N x 3

採用された回答

Dyuman Joshi
Dyuman Joshi 2022 年 4 月 7 日
%random example
y = reshape(1:30,5,6);
repmat(y,1,1,3)
ans =
ans(:,:,1) = 1 6 11 16 21 26 2 7 12 17 22 27 3 8 13 18 23 28 4 9 14 19 24 29 5 10 15 20 25 30 ans(:,:,2) = 1 6 11 16 21 26 2 7 12 17 22 27 3 8 13 18 23 28 4 9 14 19 24 29 5 10 15 20 25 30 ans(:,:,3) = 1 6 11 16 21 26 2 7 12 17 22 27 3 8 13 18 23 28 4 9 14 19 24 29 5 10 15 20 25 30

その他の回答 (0 件)

カテゴリ

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