MATLAB: I have two for loop which generate as result a vector. Every time I get a vector I want to store it inside a matrix. So, this finial matrix will have every index being a vector. I can’t find a way to do it.

vector indexing inside matrixes

Hello everybody. I'm new with Matlab and maybe the problem I'm facing is trivial, but not for me. In my script I have two for loop which generate every time as result a vector. I want to store every one of this vector inside a matrix of the results. Therefore at the end I will have a matrix which has every index being a vector. I can't find the solution. In the following I will report my script:
%data of the problem C=linspace(5,20,30000); % [MPa] alpha=linspace(0.300,0.500,30000); % power law exponent d=9.5; % bar diameter A=70.9; % bar cross-sectional area E=41400; % bar Young's modulus
x=linspace(0,750,30000);
Nl=zeros(length(C),length(C)); %matrix in which I want to store the results
for i=1:length(C)
for k=1:length(alpha)
N_x=(2.*E.*A./(1-alpha(k))).*(((2.*C(i).*(1-alpha(k)).^2)./(E.*d.*(1+alpha(k)))).^(1./(1-alpha(k)))).*x.^((1+alpha(k))./(1-alpha(k)));
Nl(i,k)=N_x';
end
end
The error I get is:
Subscripted assignment dimension mismatch.
Error in untitled6 (line 20) Nl(i,k)=N_x';

Best Answer

Nl(i,k)=N_x';
Your N_x is an array of size 3000. You are trying to put it in a single element Nl(i,k), obviously it will through error. First consider the following:
1. is x a array? If so Nl will be 3D matrix.
2. If x is scalar. Change x=linspace(0,750,30000); to single number.
Also note that if A is 3D matlab needs huge memory. You may not proceed with calculations.