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 8939835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:54:23+00:00 2026-06-15T10:54:23+00:00

I’m very new to matlab so sorry if this is a dumb question. I

  • 0

I’m very new to matlab so sorry if this is a dumb question. I have to following matrices:

im = imread('image.jpg');  %<370x366 double>
[y,x] = find(im); %x & y both <1280x1 double>
theta;  %<370x366 double> computed from gradient of image

I can currently plot points one at a time like this:

plot(x(502) + 120*cos(theta(y(502),x(502))),y(502) + 120*sin(theta(y(502),x(502))));

But what I want to do is some how increment an accumulator array, I want to increment the location of acc by 1 for every time value for that location is found.

So if x(502) + 120*cos(theta(y(502),x(502))),y(502) + 120*sin(theta(y(502),x(502)) = (10,10) then acc(10,10) should be incremented by 1. I’m working with a very large data set so I want to avoid for-loops and use something like this:

acc = zeros(size(im));
%increment value when point lands in that location
acc(y,x) = acc(x + 120*cos(theta(y,x)),y + 120*sin(theta(y,x)),'*b')) + 1;

It would be nice if the 120 could actually be another matrix containing different radius values as well.

  • 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-15T10:54:24+00:00Added an answer on June 15, 2026 at 10:54 am

    Do

    i = find(im);
    

    instead of

    [y,x] = find(im)
    

    wthis will give you linear indice of non zero values

    Also, create a meshgrid

    [x,y] = meshgrid(1:366,1:370)
    

    Now you can index both coordinated and values linearly, for example

    x(520) is 520-th point x coordinate

    im(520) is 520-th point gray value

    theta(520) is 520-th gradient value

    So, now you can just plot it:

    plot(x(i) + 120*cos(theta(i)),y(i) + 120*sin(theta(i)),'b*');
    

    x(i) means a column of i-th values

    x(i) + 120*cos(theta(i)) means a column of results

    ACCUMULATING

    I think in this case it is ok to loop for accumulating:

    acc=zeros(size(im));
    for ii=1:length(i)
        xx=round(x(ii) + 120*cos(theta(ii)));
        yy=round(y(ii) + 120*sin(theta(ii)));
        acc(xx,yy)=acc(xx,yy)+1;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This could be a duplicate question, but I have no idea what search terms
I don't have much knowledge about the IPv6 protocol, so sorry if the question
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.