Generate inner values of y for each x based on n
Show older comments
I have the following code:
clear all
clc
n = 4; % number of divisions on the boundary
x1 = linspace(0,2,n);
y1_x1 = sqrt(1-( (x1.^2)/4 ) );
y2_x1 = -sqrt(1-( (x1.^2)/4 ) );
x2 = linspace(-2,0,n);
y1_x2 = sqrt(1-( (x2.^2)/4 ) );
y2_x2 = -sqrt(1-( (x2.^2)/4 ) );
x = [x1 x1 x2 x2];
y = [y1_x1 y2_x1 y1_x2 y2_x2];
scatter(x,y)
Now, is there a way to generate the inner values of y with respect to x?
For example, as we can see in the plot, an ellipse is formed, but the points are on the boundaries, I want points within the ellipse as well, such that it uses the values of x and y already calculated and connects the y values to x like at x = 0, y = 1.0000,0.9428,0.7454,0 and at next x on both positive and negative side (x = +-0.6667), y = 0.9428,0.7454,0 so on and so forth till x = +-2
But most importantly, it all stays connected, so that all I change is the value of n and the inner points are generated.
Thanks
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


