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

  • Home
  • SEARCH
  • 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 9004695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:57:14+00:00 2026-06-16T00:57:14+00:00

After converting a sphere into a patch, I plotted the first vertex of the

  • 0

After converting a sphere into a patch, I plotted the first vertex of the patch, and realized that the vertex is not on the sphere.

Code

[faces, vertices] = surf2patch(sphere(),'triangle');
sphere();
hold on;
plot3(vertices(1,1), vertices(1,2), vertices(1,3),'*r');

The resulting figure looks like this

enter image description here

How can the vertex not be on the surface of the sphere? Am I misunderstanding something?

Thanks

  • 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-16T00:57:15+00:00Added an answer on June 16, 2026 at 12:57 am

    Explanation

    When a function is an argument to another function, Matlab treats this as a function call with a single return value. In the context of our function call above,

    [faces, vertices] = surf2patch(sphere(),'triangle');

    is equivalent to:

    z = sphere();
    [faces, vertices] = surf2patch(z,'triangle');
    

    Now recall from the documentation:

    [x, y, z] = sphere() calculates a set of 3D coordinates, [x, y, z].

    z = sphere() calculates the same [x, y, z] and only returns the z.

    sphere() with (nargout = 0) calculates the same [x, y, z], and plots it. This is the color sphere shown in the diagram above.

    Examining the source for surf2patch.m shows that when called with a single z argument, it assumes values for x and y automatically. These values are different than the [x, y, z] plotted by calling sphere() with no arguments.

    Testing

    To see for yourself, trace through the following code with a breakpoint enabled just inside surf2patch.m, and examine the input arguments:

    [x,y,z] = sphere()
    [facesA, verticesA] = surf2patch(x,y,z,'triangle')
    [facesB, verticesB] = surf2patch(sphere(), 'triangle')
    [facesC, verticesC] = surf2patch(z, 'triangle')
    

    You see that the output [facesA, verticesA] matches the plot from sphere(), whereas the second and third call to surf2patch() have no input [x, y] values, so they get auto-generated to something different than the original [x,y,z].

    Lesson

    If you expect multiple return values, assign them explicitly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After one week searching and converting many algorithm from other language into php to
I'm gettin the followig error after converting JSON echo into a dictionary, * Terminating
I converted my website from asp.net mvc 1.0 to 2.0. After converting that i
I'm having trouble converting the following VB6 code into c#4.0? This function takes a
After converting my website to WordPress I did notice that the pages doesn't have
I'm converting some Objective-C code to ARC that makes heavy use of the GCC
After converting a date/time character string into POSIXlt using strptime, I am left with
So, after converting my repository to git and doing the first build, some build
How can I keep original format of an integer values after converting it into
I have an ajax call that returns JSON data (Data Attached). After converting the

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.