facing problem in reshaping the column matrix please help
Mostrar comentarios más antiguos
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
Respuestas (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 comentario
Faheem Khan
el 5 de Mzo. de 2022
Categorías
Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!