Interpolating plot with isolines
2 ビュー (過去 30 日間)
古いコメントを表示
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.
2 件のコメント
KSSV
2021 年 5 月 20 日
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?
回答 (1 件)
Nipun
2024 年 5 月 17 日
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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!