Troubleshooting MATLAB Code: Tips for a Beginner | Findtext.m Error Help

  • Context: MATLAB 
  • Thread starter Thread starter david1986
  • Start date Start date
  • Tags Tags
    Beginner Matlab
Click For Summary
SUMMARY

The discussion centers on troubleshooting a MATLAB function named findtext that generates an error due to an undefined input argument. The user encountered the error message: "Input argument 'redc' is undefined" when executing the function. The solution provided involves correctly calling the function from the command line with specific arguments, such as findtext(2,3,4), to ensure the input parameters are defined.

PREREQUISITES
  • Basic understanding of MATLAB programming
  • Familiarity with function definitions in MATLAB
  • Knowledge of bitwise operations in MATLAB
  • Experience with MATLAB command line execution
NEXT STEPS
  • Learn how to define and call functions in MATLAB
  • Explore MATLAB's bitwise operations, including bitand and bitor
  • Investigate error handling techniques in MATLAB
  • Study MATLAB function file structure and naming conventions
USEFUL FOR

Beginner MATLAB users, programmers troubleshooting function errors, and anyone interested in understanding MATLAB's function execution and bitwise operations.

david1986
Messages
1
Reaction score
0
dear all, i am MATLAB new user and i have some problems about it.

I generated a code as below:

function data = findtext(redc,greenc,bluec)
txt=0;
if bitand(redc,4)== 4
txt=bitor(txt,128);
end
if bitand(redc,2)== 2
txt=bitor(txt,64);
end
if bitand(redc,1)== 1
txt=bitor(txt,32);
end
if bitand(greenc,4)== 4
txt=bitor(txt,16);
end
if bitand(greenc,2)== 2
txt=bitor(txt,8);
end
if bitand(greenc,1)== 1
txt=bitor(txt,4);
end
if bitand(bluec,2)== 2
txt=bitor(txt,2);
end
if bitand(bluec,1)== 1
txt=bitor(txt,1);
end
data=txt;
return

I save it as findtext.m file but i get the error as below:

? Input argument "redc" is undefined.

Error in ==> findtext at 3
if bitand(redc,4)== 4

could anyone help to answer my question ? how to solve my problem ?

thanks so much
 
Physics news on Phys.org
How are you executing your function? You should type findtext(2,3,4) from the command line to run the function. Replace the numbers with your own values.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
Replies
5
Views
2K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 52 ·
2
Replies
52
Views
13K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
8K