필터 지우기
필터 지우기

Unable to perform assignment because the left and right sides have a different number of elements, Fisheriris

조회 수: 3 (최근 30일)
I am trying to implement SVM on my data using Fisheriris example available in this site:
I received the following error for this line of code:
h(1:3) = gscatter(X(:,1),X(:,2),Y);
my X(:,1) is 259200X1 (type double), X(:,2) is 259200X1 (type double) and Y is 259200X1 (type cell), just like the example
an initialization for h is given in the previous line:
h = zeros(3 + L,1); % Preallocate for handles
in the Fisheriris example: L = 3; my L = 28;
I am using that SVM to classify to 8 different classes rather than 3 classes, like in the Fisheriris.
So what can I do to fix the error, thanks in advance.

답변 (1개)

Walter Roberson
Walter Roberson 2019년 3월 17일
gscatter() returns a number of handles equal to the number of groups it detects. Since you appear to have 8 groups, it will probably return 8 handles.
It is not recommended to initialize arrays of handles as numeric in R2014b and later. Use gobjects() instead of zeros()
  댓글 수: 3
Walter Roberson
Walter Roberson 2019년 3월 17일
Using gobjects will not solve the problem, but it might solve later problems.
You need to change the code to allocate 8+L handles instead of 3+L, and you need to change
h(1:3) = gscatter(X(:,1), X(:,2), Y);
to
h(1:8) = gscatter(X(:,1), X(:,2), Y);
I suggest that at the point just before you call gscatter, that you call save() to save your progress, and that you alter your code structure to be able to resume from saved values.

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

Community Treasure Hunt

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

Start Hunting!

Translated by