Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

조회 수: 1 (최근 30일)
I have this code (data attached) and i receive this error: "Unable to perform assignment because the indices on the left side are not compatible with the size of the right side". I tougth the problem was related to NaN and i also tried to remove them (third rows of the code) but it still give me this error.
Can someone help me?
load ('sclerometrica_equotip_v1')
misure = [ID_stop L Nn Bn];
% misure(any(isnan(misure), 2), :) = [];
ID_stop1 = misure(:,1);
L1 = misure(:,2);
Nn1 = misure(:,3);
Bn1 = misure(:,4);
k = unique(ID_stop1);
for i = 1:numel(k)
index = (ID_stop1 == k(i));
N= Nn1(index); %battute nodi
j = unique(N);
for m = 1:numel(j)
index2 = (N == j(m));
L_nodo = L1(index2);
end
end
  댓글 수: 3
EM geo
EM geo 2019년 3월 6일
yes sorry, i don't know what happens, it works also to me but it doesn't give me what i expect. I want to save the results of L_nodo in a matrix or in a cell array. For a cell array i tried this one (see modify in the code below), but in the second loop it overwrite each time the results. So i need 20 cells and in each cell there should be 20 sub-cells. After that i need an histogram for each cell.
I really don't know how to do.
k = unique(ID_stop1);
result = cell(1, numel(k));
for i = 1:numel(k)
index = (ID_stop1 == k(i));
N= Nn1(index); %battute nodi
j = unique(N);
for m = 1:numel(j)
index2 = (N == j(m));
L_nodo = L1(index2);
result{m} = L_nodo; %<--modify
end
end

댓글을 달려면 로그인하십시오.

답변 (1개)

nirit
nirit 2019년 3월 6일
편집: nirit 2019년 3월 6일
Not sure I understand.I tried you run it with /without the commented line and all worked fine without errors.
have you cleared your workspace variables before running this code?

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by