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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:30:19+00:00 2026-06-18T05:30:19+00:00

I implemented the following function in Matlab. function [x y] = cloud(a,b,phi,x0,y0,N) phi=phi*2*pi/360; m=ceil(5*N/pi);

  • 0

I implemented the following function in Matlab.

function [x y] = cloud(a,b,phi,x0,y0,N)
phi=phi*2*pi/360;
m=ceil(5*N/pi);
x=a*(-1+2*rand(m,1));
y=b*(-1+2*rand(m,1));
f=sqrt(a^2 - b^2);
indexMatrix=zeros(m,3);
indexMatrix(:,1)=x;
indexMatrix(:,2)=y;
insidePointsMatrix=zeros(1,2);
j=1;
for i=1:m
    insidePoint=sqrt(((x(i)+f).^2) + (y(i))^2) + sqrt(((x(i)-f).^2) + (y(i))^2);
    if (insidePoint<=2*a)
        indexMatrix(i,3)=1;
        %insidePointsMatrix(j,:)=indexMatrix(i,1:2);
        if j<=N
            insidePointsMatrix(j,1:2)=indexMatrix(i,1:2);
            j=j+1;
        end
    end
end

I am reading about arrayfun and cellfun, and I am wondering if it is possible to shorten the function I already implemented using it. Given a 2 x n matrix A where (u,v) are the entries for any given row, how can I return a matrix listing the output of the following formula for each row?

sqrt((u+f).^2+v.^2) + sqrt((u-v)^2+v^2)

The variables f and a are defined above. I am trying to transform a series of points into an ellipse.

  • 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-18T05:30:20+00:00Added an answer on June 18, 2026 at 5:30 am

    using find should give you the u,v coordinates:

    cond=sqrt(((x+f).^2) + y.^2) + sqrt(((x-f).^2) + y.^2) ;
    ind=find(cond<=2*a);
    u=x(ind);
    v=y(ind);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can the following function be implemented in various languages? Calculate the (x,y) point
I have this following function implemented in my app There are no errors at
I have a form (form2) and I implemented the following PUBLIC method: function ShowInterface(i:integer):boolean;
I have the following factorial function implemented in XSLT: <?xml version=1.0?> <xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform>
I've implemented following function. Showing people user A is following was simple, but showing
How is the following function implemented? func handle(pattern string, handler interface{}) { // ...
I have implemented the following function: - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
I have the following vexing problem. I have implemented the following function: function bool
I have a WPF application. I have implemented the following function, but no one
I am busy with a project where the following function needs to be implemented

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.