In an assignment A(I) = B, the number of elements in B and I must be the same error.
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Azzi Abdelmalek
2016-5-6
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 个评论
Azzi Abdelmalek
2016-5-6
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]
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!