필터 지우기
필터 지우기

Error: Subscripted assignment dimension mismatch

조회 수: 1 (최근 30일)
A
A 2011년 8월 30일
Hello,
I have a 48x64 matrix, let's call it dummy, and I have located all of the non-zero values in dummy(:).
returned as num:
num=find(dummy);
num=
783
863
864
900
901
902
1145
1146
1183
1184
1221
1222
1759
1760
1761
1797
1798
1799
1836
1915
1916
1917
1953
1954
1955
then I want to find the actual value contained at these positions in dummy(:)
values=zeros(size(num));
for i=1:length(num)
values(i,1)=dummy(num(i));
end
values=sort(values);
values=
3.0351
3.1727
3.3852
3.4728
3.4728
3.4728
3.6539
3.6539
3.8040
4.3020
4.6747
4.9834
5.1444
5.2296
5.2495
5.2708
5.2708
5.3560
5.4412
5.6222
5.7286
5.7499
5.7499
5.7499
6.1225
I now need to find the values in the original 48x64 dummy matrix which are equal to these values.
Right now, I am using:
points=zeros(length(num),2);
for i=1:length(values)
[points(i,1),points(i,2)]=find(z(:,:,pos)==values(i));
end
HOWEVER, occasionally there are repeated values, and therefore more than one [x,y] coordinate found
When this occurs, I get the error "Subscripted assignment dimension mismatch."
I have been struggling with this for some time, as it appears I cannot do:
x=find(z(:,:,pos)==values(i));
[points(i,1),points(i,2)]=X(1,1);
This error is " Indexing cannot yield multiple results."
As well, this is not ideal because I would like to have the coordinates from all values; if the above were to work it would only give me the coordinates for the first of the repeated values.
Any input is greatly appreciate, thank you in advance for your replies!

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 8월 30일
Can you try [I,J,V]=find(dummy). It gives position index and value at once.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by