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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:48:24+00:00 2026-05-29T21:48:24+00:00

I am trying to plot the following equation in MATLAB: ratio = sqrt(1+1/(kr)^2) With

  • 0

I am trying to plot the following equation in MATLAB:

ratio = sqrt(1+1/(kr)^2)

With k and r on the x and y axes, and ratio on the z axis. I used meshgrid to create a matrix with values for x and y varying from 1 to 10:

[x,y] = meshgrid([1:1:10],[1:1:10]);

The problem now is to create values for z. I’ve tried to just type the whole equation in, but that gives this result:

>> Z = sqrt(1+1/(x .* y)^2)??? 
Error using ==> mldivide
Matrix dimensions must agree.

So what I did is go to through the whole process manually, which produces the right graph in the end:

z = z^2;
z = 1 ./ z;
z = 1 + z;
z = sqrt(z);
mesh(x,y,z)

Is there a more elegant way to do this? Or a way to type in the equation and let MATLAB handle the rest?

  • 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-05-29T21:48:27+00:00Added an answer on May 29, 2026 at 9:48 pm

    Try this:

     Z = sqrt(1+1./(x .* y).^2);
     surf(Z);
    

    The problem that you had is related to using / instead of ./ and ^2 instead of .^2

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

Sidebar

Related Questions

As question, I am trying to create a plot using the following code: chart.demo.sex.age
I am trying to create nice (!) polar plot with the following data. gr1
I am trying to plot the following ! from numpy import * from pylab
I have the following data set that I am trying to plot with ggplot2,
I am trying to change the size of each plot on the following chart
I am trying to plot some one-dimensional data onto a 2-D plot in MATLAB.
I am trying to plot the following numbers on a log scale as a
I am trying to plot side by side the following datasets dataset1=data.frame(obs=runif(20,min=1,max=10)) dataset2=data.frame(obs=runif(20,min=1,max=20)) dataset3=data.frame(obs=runif(20,min=5,max=10))
I'm trying to plot heatmap in ggplot2 using csv data following casbon's solution in
I'm trying to create a ggplot2 plot with the legend beneath the plot. 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.