Declrarion of an array using tilde (~). what is the correct way of using it, because my code prompts me incorrect use of tilde.
이전 댓글 표시
this part of my code that genrate the error
[~, i] == max(y);
if i == D(k)
acc = acc + 1;
end
채택된 답변
추가 답변 (1개)
John D'Errico
2022년 6월 16일
편집: John D'Errico
2022년 6월 16일
This is a test:
if i == D(k)
It is the correct way to use == because == is a comparison operator.
However, this other line is an assignment. That is, you are calling the function max, and returning a result in the variable i.
[~, i] == max(y);
The error mesage about ~ that you report is confusing to you. The problem is, MATLAB was also confused, because you used invalid syntax there. So MATLAB generated whatever error it could. The correct syntax to perform an assignment uses a SINGLE = operator, thus:
[~, i] = max(y);
카테고리
도움말 센터 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!