Interpolating plot with isolines (2024)

7 views (last 30 days)

Show older comments

Jan Jurkiewicz on 20 May 2021

  • Link

    Direct link to this question

    https://control.mathworks.com/matlabcentral/answers/834903-interpolating-plot-with-isolines

  • Link

    Direct link to this question

    https://control.mathworks.com/matlabcentral/answers/834903-interpolating-plot-with-isolines

Answered: Nipun about 11 hours ago

Hello, I have some problems with digitalizing and interpolating a plot with some isolines. Below is a picture of the plot I would like to digitize. I would also like the constant angle lines to be plotted on Zaxis of 3d plot. I'm not sure how to prepare my data for this interpolation as for now I came up with getting x and y values for some points on the isolines. My data looks like this:

x y z

0,057301 1,377258 15

0,154268 1,271617 15

0,247804 1,137435 15

0,33806 0,990584 15

0,409596 0,869301 15

0,480922 0,725797 15

....

I tried usind griddata() but what i get instead of matrix is a table array with one row and the values extrapolated for angles below 15 degrees are "NaN". I'm then unable to plot this. I also tried griddedinterpolant() but I get sample values error. Do you have any tips on how to approach my problem? What I need are angle values in spaces between the isolines.

Interpolating plot with isolines (2)

2 Comments

Show NoneHide None

KSSV on 20 May 2021

Direct link to this comment

https://control.mathworks.com/matlabcentral/answers/834903-interpolating-plot-with-isolines#comment_1531508

  • Link

    Direct link to this comment

    https://control.mathworks.com/matlabcentral/answers/834903-interpolating-plot-with-isolines#comment_1531508

Question is not clear...why you want to use griddata? The value og z is always fixed i.e. 15...What exactly you want to do?

Jan Jurkiewicz on 20 May 2021

Direct link to this comment

https://control.mathworks.com/matlabcentral/answers/834903-interpolating-plot-with-isolines#comment_1533028

  • Link

    Direct link to this comment

    https://control.mathworks.com/matlabcentral/answers/834903-interpolating-plot-with-isolines#comment_1533028

  • CN(J).png

This data is just a sample of all sample points I took. Next smaple points have z value fixed on 20 then on 25 and so on untill 40. I want to be able to estimate the value of the angle in for example those red crosses marked on the picture. I would also like to be able to plot the interpolated data with for example plot3() command. Also i would like to extrapolate the data so i can also get values of angle below 15 degree and above 40.

Sign in to comment.

Sign in to answer this question.

Answers (1)

Nipun about 11 hours ago

  • Link

    Direct link to this answer

    https://control.mathworks.com/matlabcentral/answers/834903-interpolating-plot-with-isolines#answer_1459521

  • Link

    Direct link to this answer

    https://control.mathworks.com/matlabcentral/answers/834903-interpolating-plot-with-isolines#answer_1459521

Open in MATLAB Online

Hi Jan,

I understand that you are trying to digitize and interpolate a plot with isolines to extract and plot constant angle lines on a 3D plot. You have collected some data points along these isolines, which include (x), (y), and (z) values, where (z) represents the angle value at each (x, y) location. Your goal is to interpolate these data points to fill in the gaps between the isolines, especially for angle values not directly measured.

Given the nature of your problem, it seems like you're facing challenges with griddata resulting in NaN values for extrapolated areas and issues with griddedInterpolant due to sample values errors. These problems often arise from how the data is prepared and fed into these functions or from attempting to extrapolate beyond the bounds of your data.

Here's a structured approach to tackle your problem using MATLAB:

1. Preparing Your Data

Ensure your data is in the correct format. Your data should be in three separate vectors of the same length, corresponding to (x), (y), and (z) values. For example:

x = [0.057301, 0.154268, 0.247804, 0.33806, 0.409596, 0.480922, ...];

y = [1.377258, 1.271617, 1.137435, 0.990584, 0.869301, 0.725797, ...];

z = [15, 15, 15, 15, 15, 15, ...]; % Assuming all these are at the same angle for demonstration

2. Use griddata for Interpolation

Create a grid on which to interpolate your (z) values and use griddata for the interpolation. To address the issue of NaN values for extrapolated areas, you can limit your interpolation to the convex hull of your data points or use nearest neighbor interpolation to fill in NaN values.

% Create a grid

[xq, yq] = meshgrid(linspace(min(x), max(x), 100), linspace(min(y), max(y), 100));

% Perform interpolation

zq = griddata(x, y, z, xq, yq, 'linear');

% Optionally, handle NaN values by filling with nearest known values

% This is useful for points outside your dataset's convex hull

zq(isnan(zq)) = griddata(x, y, z, xq(isnan(zq)), yq(isnan(zq)), 'nearest');

3. Plotting the Interpolated Data

After interpolating the (z) values on your grid, you can plot the results to visualize the angle isolines in 3D.

surf(xq, yq, zq); % Creates a 3D surface plot

xlabel('X');

ylabel('Y');

zlabel('Z (Angle)');

title('Interpolated Isolines in 3D');

For more information on using "griddata" in MATLAB, refer to the following MathWorks documentation: https://in.mathworks.com/help/matlab/ref/griddata.html#d126e641088

For more information on using "surf" function in MATLAB, refer to the following MathWorks documentation: https://in.mathworks.com/help/matlab/ref/surf.html#d126e1637398

Hope this helps.

Regards,

Nipun

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

See Also

Categories

MATLABMathematicsInterpolation

Find more on Interpolation in Help Center and File Exchange

Tags

  • interpolation
  • griddeddata()

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


Interpolating plot with isolines (6)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

Contact your local office

Interpolating plot with isolines (2024)
Top Articles
Latest Posts
Article information

Author: Twana Towne Ret

Last Updated:

Views: 5513

Rating: 4.3 / 5 (64 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Twana Towne Ret

Birthday: 1994-03-19

Address: Apt. 990 97439 Corwin Motorway, Port Eliseoburgh, NM 99144-2618

Phone: +5958753152963

Job: National Specialist

Hobby: Kayaking, Photography, Skydiving, Embroidery, Leather crafting, Orienteering, Cooking

Introduction: My name is Twana Towne Ret, I am a famous, talented, joyous, perfect, powerful, inquisitive, lovely person who loves writing and wants to share my knowledge and understanding with you.