matlab描绘曲线
大神们,直线的方程为y=k*x+b,我想通过不断改变斜率k的方式绘制成曲线,用matlab如何编程实现。下面是我在vc++6.0平台用openGL实现的图形,代码如下:#include <gl/glut.h>
#include <gl/GL.h>
#include<math.h>
#include<stdio.h>
#define PI 3.1415926
void display()
{
float k = 1,b = 0.5;
float x,y;
glBegin(GL_LINE_STRIP);//首尾相接的线段
for(x = -1.0;x<=1.0;x+=0.02)
{
y = k * x + b;
glVertex2f(x,y);
k = k - 0.02;
}
glEnd();
glFlush();
}
void main(int argc,char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(0,0);
glutCreateWindow("polygon");
glutDisplayFunc(display);
glutMainLoop();
}
请各位大神帮帮忙,在此谢过!