Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8830641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:08:32+00:00 2026-06-14T08:08:32+00:00

I have written a code in matlab script. I need to finish it up

  • 0

I have written a code in matlab script. I need to finish it up by creating a Function for center.

Here is the sample code i written

while(1)        % infinite loop

trigger(obj); 
im=getdata(obj,1);   %get the image

trigger(obj); 
im1=getdata(obj,1);  % the first time triggering occurs the image is just
                              % noise. Thus the 2nd image is used.
b=rgb2gray(im1);      % convert to grayscale
a=roicolor(b,[100:118]);  %define a region of interest
a=~a;

c=center(a);
                  % use disp(c) to see the values, while testing
if (c(2)>190)
fwrite(ser,'r');  % send move right
elseif (c(2)<170 && c(2)>10)
fwrite(ser,'l');
elseif c(2)<170
fwrite(ser,'l'); % stop

now in this center(a) its not a predefined function in matlab, its a user defined one.

The function center(a) that I have used is not an inbuilt function. I would suggest you write a function for center which I can work on

I want you people to help me to create a function in matlab and to call the user defined function, when ever I needed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:08:33+00:00Added an answer on June 14, 2026 at 8:08 am

    just create a file called center.m put all your code in there and start the file (at the top) with something like:

    function c = center(a);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written code to perform a function that could take a while to
I'm trying to rewrite code I've written in matlab in C++ instead. I have
I have written the following code in MATLAB to process large images of the
I have written a script in MATLAB, where I am retrieving rows and columns
I have this line of code in MATLAB, written by someone else: c=a.'/b I
I have written code for performing calculations. There is a loop in the code.
I have a certain code written in Matlab. I wanted to obtain similar results
I have written a code in MATLAB that allows me to generate a random
I have written a code for the bisection algorithm in MatLab. I have based
I have written some piece of code for my program in Matlab 7.10.0 which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.