Disk out of an arc
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Minas Emiris
am 11 Apr. 2018
Kommentiert: Minas Emiris
am 14 Apr. 2018
I was wondering how to create a matrix of points inside an arc of a specific radius R. My goal is my matrix to have a sufficient number of elements, so that when creating a 2D/3D plot, the shape appear as a surface. My idea is to create a set of many arcs, so that the shape appears as continuous. I used a fairly easy code to create arcs of angle pi/8:
R = 0;
theta = pi/8;
x = linspace(R*cos(theta),R,100);
y = sqrt (R^2 - x.*x);
plot(x,y)
xlim([0 5])
ylim([0 5])
hold on
R = 1;
x = linspace(R*cos(theta),R,100);
y = sqrt (R^2 - x.*x);
plot(x,y)
hold on
R = 2;
x = linspace(R*cos(theta),R,100);
y = sqrt (R^2 - x.*x);
plot(x,y)
hold on
R = 3;
x = linspace(R*cos(theta),R,100);
y = sqrt (R^2 - x.*x);
plot(x,y)
hold on
R = 4;
x = linspace(R*cos(theta),R,100);
y = sqrt (R^2 - x.*x);
plot(x,y)
hold on
R = 5;
x = linspace(R*cos(theta),R,100);
y = sqrt (R^2 - x.*x);
plot(x,y)
hold on
How can I continue a similar procedure with a function that avoids writing so many values of R manually? I thought using R = linspace (0,Rmax,N), where Rmax is the radius of the disk, N the number of arcs, but his doesn't appear to work; there is an error with the functions I am using.
2 Kommentare
Jan
am 11 Apr. 2018
"doesn't appear to work" and "there is an error" is less useful to clarify the problem. Please post a copy of the complete error message.
What about using a surface to display a surface?
Akzeptierte Antwort
Are Mjaavatten
am 11 Apr. 2018
Bearbeitet: Are Mjaavatten
am 11 Apr. 2018
Is this what you want?
R = 5;
x = linspace(R*cos(theta),R,100);
y = sqrt (R^2 - x.*x);
x = [0,x];
y = [0,y];
patch(x,y,'b')
Alternatively, by plotting one arc at a time, as you proposed:
figure;
hold on
N = 300;
Rmax = 5;
R = linspace (0,Rmax,N);
for i = 1:N
x = linspace(R(i)*cos(theta),R(i),100);
y = sqrt (R(i)^2 - x.*x);
plot(x,y,'b');
end
6 Kommentare
Are Mjaavatten
am 12 Apr. 2018
This does what you ask for:
[x,ix] = sort(X(:));
y = Y(ix);
plot(x,y,'.')
But somehow I doubt that this is what you want.
I really hate this this damn machine,
I wish that they would sell it.
It never does quite what I mean
but only what I tell it!
The programmer's lament ( from the time before PCs):
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!