facing problem in reshaping the column matrix please help
이전 댓글 표시
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
답변 (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
카테고리
도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!