How can I fit multiple column matrix in a matrix?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Jhilam Mukherjee
il 20 Ott 2015
I want to create a M*N matrix, whose each column contains one column matrix of different features namely T(i),T1(i),T2(i),T4(i),T5(i). While I want to assign all the column matrix the final matrix shows last row value rather than whole matrix. How can I get whole matrix
X_entropy=[0.0640;0.0658;0.0282;0.0286;0.1237;0.9477;0.0124;0.1100;0.8323;1.2819;0.9289;0.9040;0.7039;0.0103;];
myEdist_entropy = squeeze(sqrt(sum(bsxfun(@minus,X_entropy,reshape(X_entropy',1,size(X_entropy,2),size(X_entropy,1))).^2,2)));
x_entropy=sum(myEdist_entropy);
y_entropy=mean(x_entropy);
s=length(X_contrast);
for i=1:s
%a=
T(i)=X_contrast(i)*y_contrast;
T1(i)=X_correlation(i)*y_correlation;
T2(i)=X_energy(i)*y_energy;
T3(i)=X_homogeniety(i)*y_homogeniety;
T4(i)=X_standard_deviation(i)*y_standard_deviation;
T5(i)=X_entropy(i)*y_entropy;
M=[T(i) T1(i) T2(i) T3(i) T4(i) T5(i)]
end
Each X_feature contains same number of element
1 Commento
Harish kumar Kotapally
il 20 Ott 2015
Use cell command for suppose if A is required M*N matrix. code:
A=cell(1,N)
for i=1:1:M
A{1,i}=T{i};
end
A=cell2mat(A);
Risposta accettata
Guillaume
il 20 Ott 2015
Either, replace the assignment in the loop by an indexed assignment:
M(i, :) = [T(i) T1(i) T2(i) T3(i) T4(i) T5(i)]; %surely you can come up with better variable names than Tn.
Or simply do the concatenation after the loop:
M = [T T1 T2 T3 T4 T5];
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!