MATLAB Matlab find() function in script

  • Thread starter Thread starter phyhari
  • Start date Start date
  • Tags Tags
    Function Matlab
AI Thread Summary
Using square brackets in MATLAB scripts leads to a parse error, as they are not valid for function arguments. The correct syntax for the find function requires parentheses. To find matrix indices where M equals 10, use the command [r, c] = find(M == 10). This adjustment resolves the issue and allows the script to run correctly.
phyhari
Messages
2
Reaction score
0
SOLVED.
Hi All!
Brief version:
I would like to use statement starting with [ in Matlab script. Is it possible, if yes, how?

Longer version:
I'm writing code in matlab. I need to find matrix indices, for which the statement M==10 is true. (I found find() function, which is perfect for the task).

[r,c]=find[M==10];

It works perfectly within the command window, but not in my script.
I get an error message, stating: parse error at '[' ... not valid MATLAB script
Can you help, or I must write an algorithm for finding indices? :S

Thanks in advance!
 
Last edited:
Physics news on Phys.org
Use (), not [] for the find argument
 
Thank you! :) That was the problem. As you can see I'm just started coding in matlab...
 

Similar threads

Replies
4
Views
1K
Replies
5
Views
2K
Replies
5
Views
3K
Replies
2
Views
2K
Replies
6
Views
4K
Replies
2
Views
1K
Back
Top