facing problem in reshaping the column matrix please help
Afficher commentaires plus anciens
clc;
close all;
clear all;
printlevel=3;
n=input('n=');
for kk = 0:n
for ii = 0:n
for jj = 0:n
E = ((nchoosek(n,ii))/(2*n+kk+1))*((nchoosek(n,jj))/(nchoosek(2*n+kk,ii+kk+jj)))
end
ee(kk+1,ii+1) = reshape(E,n+1,1)
end
end
Réponses (1)
Maybe you mean:
n = 3;
E = zeros(n+1, 1); % Pre-allocate in wanted dimension instead of reshape
ee = zeros(n+1, n+1, n+1); % Preallocate!
for kk = 0:n
for ii = 0:n
for jj = 0:n
E(jj + 1) = (nchoosek(n,ii) / (2*n+kk+1)) * ...
(nchoosek(n,jj) / nchoosek(2*n+kk, ii+kk+jj));
% ^^^^^^^^
end
ee(kk+1, ii+1, :) = E;
% ^ E is a vector, you cannot assign it to the
% scalar ee(kk+1,ii+1)
end
end
ee
1 commentaire
Faheem Khan
le 5 Mar 2022
Catégories
En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!