In an assignment A(I) = B, the number of elements in B and I must be the same error.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hamza Karakurt
am 6 Mai 2016
Kommentiert: Hamza Karakurt
am 7 Mai 2016
Hello, I am trying to make a script to use in some analysises but I have this "In an assignment A(I) = B, the number of elements in B and I must be the same" error. I think it is a common error. My codes are shown below. I have 3 data sets and it worked it 2 of them but the 3rd one giving that error to me. Error is in the line "N(j)=find(M~=0)". When I try to run the code, I=6042 logical, K=[31;32;33;34;35] , M=1095 logical, N=[109,250,486,744,750,1004], i=9 and j=4. I attached my data as .mat file. I have no idea why this code is not working. I really need help.
Good day
for i=1:numel(Full_Result.Nodes_Names)
I=strcmp(Full_Result.Nodes_Names{i, 1},Network.Nodes);
Full_Result.Nodes_NEdges(i)=sum(I);
%Listedeki Hangi metabolitlerle eşlesiyor
K=find(I~=0);
Full_Result.ESC{i,1}=Network.Edges(K',1);
for j=1:numel(K)
M=strcmp(Network.Edges{K(j),1},Pvalues.Edges);
N(j)=find(M~=0);
end
%Calculate the aggregated Z-score for the metabolite
Full_Result.Nodes_ZScores(i)=sum(Pvalues.Zscores(N))/sqrt(numel(N));
Full_Result.Nodes_meanZ(i)=mean(Pvalues.Zscores(N));
Full_Result.Nodes_stdZ(i)=std(Pvalues.Zscores(N));
end
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 6 Mai 2016
load error_matrixes
for i=1:numel(Full_Result.Nodes_Names)
I=strcmp(Full_Result.Nodes_Names{i, 1},Network.Nodes);
Full_Result.Nodes_NEdges(i)=sum(I);
%Listedeki Hangi metabolitlerle eşlesiyor
K=find(I~=0);
Full_Result.ESC{i,1}=Network.Edges(K',1);
N=cell(1);
for j=1:numel(K)
M=strcmp(Network.Edges{K(j),1},Pvalues.Edges);
N{j}=find(M~=0);
end
%Calculate the aggregated Z-score for the metabolite
Full_Result.Nodes_ZScores(i)=sum(Pvalues.Zscores(N{j}))/sqrt(numel(N));
Full_Result.Nodes_meanZ(i)=mean(Pvalues.Zscores(N{j}));
Full_Result.Nodes_stdZ(i)=std(Pvalues.Zscores(N{j}));
end
4 Kommentare
Azzi Abdelmalek
am 6 Mai 2016
If find(M~=0) gives just one value you can write N(j)=find(M~=0) but if the result have different sizes, for example find(M~=0) gives [1 3]; then [4 5 7], what is the meaning of?
N(1)=[1 3]
N(2)=[4 5 7]
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!