Octave 如何在GNU八度音阶中画圆
在这种情况下:Octave 如何在GNU八度音阶中画圆,octave,computational-geometry,Octave,Computational Geometry,在这种情况下: R = 10; Center = [5,8]; circle(Center,R,1000,'b-'); hold on plot(Center(1),Center(2),'g.') 同样的MatLab代码不适用于GNU倍频程。给定中心x、y坐标和半径,哪个倍频程代码会绘制一个圆?如果您想要一个可重用的函数,这里有一种可能性: t = linspace(0,2*pi,100)'; circsx = r.*cos(t) + x; circsy = r.*sin(t) + y;
R = 10;
Center = [5,8];
circle(Center,R,1000,'b-');
hold on
plot(Center(1),Center(2),'g.')
同样的MatLab代码不适用于GNU倍频程。给定中心x、y坐标和半径,哪个倍频程代码会绘制一个圆?如果您想要一个可重用的函数,这里有一种可能性:
t = linspace(0,2*pi,100)';
circsx = r.*cos(t) + x;
circsy = r.*sin(t) + y;
plot(circsx,circsy);
function [h, hc] = circles(x,y,r,cmrk)
% CIRCLES plot 2-D circles, given a set of center coordinates and radii.
%
% Description:
%
% Plot 2-D circles, given a set of center coordinates and radii. Values
% can be vectors or matrices, as long as dimensions are consistent. If
% a marker type (e.g. '+') is also given, circle centers will be marked
% with it. The function returns a vector of handles for each circle and
% a handle for all the center markers, if plotted.
assert(size(x)==size(y), 'Mismatching sizes')
assert(size(y)==size(r), 'Mismatching sizes')
if (nargin==4)
hc = scatter(x,y,[],[],cmrk);
end
axis([min(x-r) max(x+r) min(y-r) max(y+r)], 'equal');
a = linspace(0, 2*pi, 12);
dx = sin(a); dy = cos(a);
hold on
for i=1:numel(x);
h(i) = line(x(i)+dx*r(i), y(i)+dy*r(i));
end
hold off
下面是一个用法示例:
x = 0:.1:2*pi; y = sin(x); r = rand(size(x))*.3;
circles(x, y, r, '+')
以GNU倍频程绘制一个圆:
x = -3:0.01:3;
y = (4 - x .^ 2) .^ 0.5;
figure; plot(x,y); hold on; plot(x,-y);
octave> x = -1:0.01:1;
octave> y = (1 - x .^ 2) .^ 0.5;
octave> plot(x,y, "linewidth", 4, x,-y, "linewidth", 4);
octave> r = 1;
octave> t = linspace(0,2.*pi,1);
octave> circsx = r.*cos(t) + x;
octave> circsy = r.*sin(t) + y;
octave> plot(circsx,circsy, "linewidth", 4, circsx, -circsy, "linewidth", 4);
画一个圆,方程x^2+y^2=4 使用倍频程额外包倍频程几何体,您可以将函数用作
pkg安装路径到文件.tar.gz
pkg装载几何图形
如何在gnu倍频程版本3.8中绘制圆:
x = -3:0.01:3;
y = (4 - x .^ 2) .^ 0.5;
figure; plot(x,y); hold on; plot(x,-y);
octave> x = -1:0.01:1;
octave> y = (1 - x .^ 2) .^ 0.5;
octave> plot(x,y, "linewidth", 4, x,-y, "linewidth", 4);
octave> r = 1;
octave> t = linspace(0,2.*pi,1);
octave> circsx = r.*cos(t) + x;
octave> circsy = r.*sin(t) + y;
octave> plot(circsx,circsy, "linewidth", 4, circsx, -circsy, "linewidth", 4);
代码:
x = -3:0.01:3;
y = (4 - x .^ 2) .^ 0.5;
figure; plot(x,y); hold on; plot(x,-y);
octave> x = -1:0.01:1;
octave> y = (1 - x .^ 2) .^ 0.5;
octave> plot(x,y, "linewidth", 4, x,-y, "linewidth", 4);
octave> r = 1;
octave> t = linspace(0,2.*pi,1);
octave> circsx = r.*cos(t) + x;
octave> circsy = r.*sin(t) + y;
octave> plot(circsx,circsy, "linewidth", 4, circsx, -circsy, "linewidth", 4);
语言化:
x = -3:0.01:3;
y = (4 - x .^ 2) .^ 0.5;
figure; plot(x,y); hold on; plot(x,-y);
octave> x = -1:0.01:1;
octave> y = (1 - x .^ 2) .^ 0.5;
octave> plot(x,y, "linewidth", 4, x,-y, "linewidth", 4);
octave> r = 1;
octave> t = linspace(0,2.*pi,1);
octave> circsx = r.*cos(t) + x;
octave> circsy = r.*sin(t) + y;
octave> plot(circsx,circsy, "linewidth", 4, circsx, -circsy, "linewidth", 4);
以.01
的增量创建一个介于-1和1之间的列表,以表示x轴。y轴是圆的直径减去x平方的每个索引处的值,所有值均升高到0.5
绘制x和y(蓝色),给出圆的上半部分,然后绘制x到-y,反转顶部(绿色),创建圆的下半部分
或者,使用linspace:
代码:
x = -3:0.01:3;
y = (4 - x .^ 2) .^ 0.5;
figure; plot(x,y); hold on; plot(x,-y);
octave> x = -1:0.01:1;
octave> y = (1 - x .^ 2) .^ 0.5;
octave> plot(x,y, "linewidth", 4, x,-y, "linewidth", 4);
octave> r = 1;
octave> t = linspace(0,2.*pi,1);
octave> circsx = r.*cos(t) + x;
octave> circsy = r.*sin(t) + y;
octave> plot(circsx,circsy, "linewidth", 4, circsx, -circsy, "linewidth", 4);
语言化:
x = -3:0.01:3;
y = (4 - x .^ 2) .^ 0.5;
figure; plot(x,y); hold on; plot(x,-y);
octave> x = -1:0.01:1;
octave> y = (1 - x .^ 2) .^ 0.5;
octave> plot(x,y, "linewidth", 4, x,-y, "linewidth", 4);
octave> r = 1;
octave> t = linspace(0,2.*pi,1);
octave> circsx = r.*cos(t) + x;
octave> circsy = r.*sin(t) + y;
octave> plot(circsx,circsy, "linewidth", 4, circsx, -circsy, "linewidth", 4);
绘制一个圆。在“geometry”包中有一个内置函数,可用于绘制不同的几何形状。下面是圆的代码:
pkg load geometry
drawCircle (x0, y0, r)
我有几种画圆的方法,这是一种简单的方法
pkg load geometry
x=0;
y=0; #center point ordered pair
r1=10; #radius of circule
h1=drawCircle(x,y,r1);
如果你想让卓尔再绕一圈
hold on;
r2=8;
h2=drawCircle(x,y,r2);
另一种方法是
angle=linspace(0,2*pi,360);
r=5; #radius
x=2;
y=5; #x and y is hear center point
horizantalValue=r*cos(angle)+x;
verticalValue=r*sin(angle)+y;
plot(verticalValue,horizantalValue);
您能否提供一个完整的示例,说明您正在使用的八度音阶版本?八度音阶3.2.4的完整示例:。这就是它的样子:为什么不把这个函数贡献给倍频程呢?它写得很好,可能对未来的用户有用。我只是将其重命名为与Matlab兼容。