Expression or statement is incorrect--possibly unbalanced (, {, or [.
조회 수: 2 (최근 30일)
이전 댓글 표시
hello every body i have an error ??? Error: File: test.m Line: 31 Column: 3 exactely in [~,scores] = predict(cl,xGrid); i have Matlab 7.8.0 (R2009a)
- rand(1); % For reproducibility
- r = sqrt(rand(100,1)); % Radius
- t = 2*pi*rand(100,1); % Angle
- data1 = [r.*cos(t), r.*sin(t)]; % Points
- r2 = sqrt(3*rand(100,1)+1); % Radius
- t2 = 2*pi*rand(100,1); % Angle
- data2 = [r2.*cos(t2), r2.*sin(t2)]; % points
- figure;
- plot(data1(:,1),data1(:,2),'r.','MarkerSize',15)
- hold on
- plot(data2(:,1),data2(:,2),'b.','MarkerSize',15)
- ezpolar(@(x)1);ezpolar(@(x)2);
- axis equal
- hold off
- data3 = [data1;data2];
- theclass = ones(200,1);
- theclass(1:100) = -1;
- %Train the SVM Classifier
- cl = fitcsvm(data3,theclass,'KernelFunction','rbf',...
- 'BoxConstraint',Inf,'ClassNames',[-1,1]);
- % Predict scores over the grid
- d = 0.02;
- [x1Grid,x2Grid] = meshgrid(min(data3(:,1)):d:max(data3(:,1)),...
- min(data3(:,2)):d:max(data3(:,2)));
- xGrid = [x1Grid(:),x2Grid(:)];
- [~,scores] = predict(cl,xGrid);
- % Plot the data and the decision boundary
- figure;
- h(1:2) = gscatter(data3(:,1),data3(:,2),theclass,'rb','.');
- hold on
- ezpolar(@(x)1);
- h(3) = plot(data3(cl.IsSupportVector,1),data3(cl.IsSupportVector,2),'ko');
- contour(x1Grid,x2Grid,reshape(scores(:,2),size(x1Grid)),[0 0],'k');
- legend(h,{'-1','+1','Support Vectors'});
- axis equal
- hold off
답변 (1개)
Steven Lord
2017년 11월 10일
The ability to ignore specific input or output arguments in function calls using the tilde operator was introduced in release R2009b. Replace ~ with a dummy variable name, like dummy, for older releases.
댓글 수: 3
per isakson
2017년 11월 11일
fitcsvm - Train binary support vector machine classifier
fitcsvm trains or cross-validates a support vector machine (SVM)
model for two-class (binary) classification on a low- through
moderate-dimensional predictor data set. fitcsvm supports...
Documentation > Statistics and Machine Learning Toolbox > Classification > Support Vector Machine Classification
Walter Roberson
2017년 11월 11일
That routine was introduced in R2014a.
In your software release there was no built-in SVM in any toolbox, so people would compile and link the third party libsvm
참고 항목
카테고리
Help Center 및 File Exchange에서 Classification Ensembles에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!