Clear Filters
Clear Filters

Incrusting polyshape datas in my plotm map

3 views (last 30 days)
Hi,
So here is my first map, where i want to add information on it.
It is created thanks to this code (and all the data i wrote upper in my code):
I am using plotm and the mapping toolbox to get it.
Now, i have this other map made on another script:
What's interested me with it is all the shape of color. And I want to do the same on my first map. I am using polyshape to got it, but it's not working on plotm:
pink = polyshape([48.47 46.39 46.44 46.72 47.93 48.41 48.31 48.94], [-0.14 1.17 2.21 3.65 4.28 3.38 2.00 1.48]);
plot(pink)
hold on
That's what i am doing to get the pink shape at the bottom for example.
The fact is pink is type polyshape, and polyshape doesn't work (or I am doing it wrong) with plotm because it's not the good type.
Is there a way to dodge this problem?
I have already read the doc about polyshape and plotm without finding an answer, and also tried something found on the internet that looks like this:
and i tried to change/adapt with plotm without succes.
Thanks for your response,
Lucas!

Answers (1)

Supraja
Supraja on 5 May 2023
Think about how polyshape works:
  • You need a closed region.
  • Inside this interval of x-values of your ROI you need correspondig y-values
  • You need several points for the nonlinear part of your region
  • The linear part of your region should be able to be described using 2 points --> you can guess which points this will be...
  • Using this thoughts you can construct a vector pair x,y that describes the ROI properly for the usage of polyshape.
The below is code example to plot a particular region.
x = -10:1:10;
y1 = -x.^2 + 100;
y2 = 0.*x + 50;
xcut1 = fzero(@(x)-x.^2 + 100 - 50,-7);
xcut2 = fzero(@(x)-x.^2 + 100 - 50,7);
x_linear = [xcut1 xcut2];
y_linear = [50 50];
x_quad = linspace(xcut1, xcut2, 25);
y_quad = -x_quad.^2 + 100;
M = polyshape([x_linear, x_quad], [y_linear, y_quad],'simplify', false);
plot(x,y1,x,y2)
hold on
plot(M)

Categories

Find more on Elementary Polygons in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!