求c语言程序转变成matlab语言程序高手

/ yiqiz1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "stdio.h"
#include "math.h"

int main(int argc, char* argv[])
{
int i;
double a[501],b[501],c[501],x[501],y[501],tb[501];
double cc;

a[0]=0*3.14159/180;
printf("输入出射光最大角度α:\n");
scanf("%lf",&a[500]);

printf("输入光源最大发光角θ的余角:\n");
scanf("%lf",&c[500]);
cc=((90-c[500])/500.0)*3.14159/180;
c[0]=90*3.14159/180;

x[0]=0;

printf("输入z=0时的y值:\n");
scanf("%lf",&y[0]);

printf("0 %7.3f %7.3f\n",y[0],x[0]);
for(i=1;i<501;i++)
{
c[i]=c[0]-i*cc;
a[i]=atan((((cos(c[i])-cos(c[i-1]))/cos(c[500]))*tan(a[500]*3.14159/180))+tan(a[i-1]));

tb[i]=(1.4935*cos(c[i])-sin(a[i]))/(1.4935*sin(c[i])-cos(a[i]));
//x[i]=(y[i-1]-x[i-1]*tb[i])/(tan(c[i])-tb[i]);
x[i]=(y[i-1]+x[i-1]*tb[i])/(tan(c[i])+tb[i]);
y[i]=x[i]*tan(c[i]);
printf("0 %7.3f %7.3f\n",y[i],x[i]);
}

return 0;
}
求高手把这个程序转变成matlab语言程序 能够在matlab中运行。。谢谢
%先试一下
a=ones(1,501);
b=ones(1,501);
c=ones(1,501);
x=ones(1,501);
y=ones(1,501);
tb=ones(1,501);
a(1) = 0*3.14159/180;
disp('输入出射光最大角度α:\n');
a(501)=input('a(501)=');
disp('输入光源最大发光角θ的余角:\n')
c(501)=input('c(501)=');
cc=((90-c(501))/500.0)*3.14159/180;
c(1)=90*3.14159/180;
x(1)=0;
disp('输入z=0时厅祥的y值:\n')
y(1)=input('y(1)=');
disp(sprintf('0 %7.3f %7.3f\n'薯灶,y(1),x(1)));
for i=2:501
c(i)=c(1)-i*cc;
a(i)=atan((((cos(c(i))-cos(c(i-1)))/扮手搏cos(c(500)))*tan(a(500)*3.14159/180))+tan(a(i-1)));
tb(i)=(1.4935*cos(c(i))-sin(a(i)))/(1.4935*sin(c(i))-cos(a(i)));
x(i)=(y(i-1)+x(i-1)*tb(i))/(tan(c(i))+tb(i));
y(i)=x(i)*tan(c(i));
disp(sprintf('0 %7.3f %7.3f\n',y(i),x(i)));
end
可以试试Matlab的混合编程,Matlab有这样的接口