简单的matlab代码转换,不胜感激!
时间:10-02
整理:3721RD
点击:
各位大神,我是FPGA新手。导师最近给我分配任务让我把以下很简单的matlab代码用verilog语言在quartus里描述出来,可是我真的是没有丝毫头绪,不知道如何下手,心里非常着急。请各位大神帮忙转成verilog语言,这样我就有了一个实例,之后就可以按照这个实例学习研究了,多谢!不胜感激!
clear Phmag;
clear Pang;
delT=1/(60*48);
sample=0:47;
f=60;
Ref1=sin(2*pi*f*delT*sample);
Ref2=cos(2*pi*f*delT*sample);
A=[Vmachine Imachine Vinfbus Iinfbus Pmachine];
data1=A(:,1);
for count=1:length(data1)-length(sample)
Sumrealx=0;
Sumrealy=0;
for count1=1:length(sample)
Sumrealx=Sumrealx+data1(count+count1-1)*Ref1(count1);
Sumrealy=Sumrealy+data1(count+count1-1)*Ref2(count1);
end
Sumrealx=Sumrealx*2/length(sample);
Sumrealy=Sumrealy*2/length(sample);
Phmag(count)=sqrt(Sumrealx*Sumrealx+Sumrealy*Sumrealy);
Pang(count)=atan2(Sumrealy,Sumrealx)*180/pi;
end
clear Phmag;
clear Pang;
delT=1/(60*48);
sample=0:47;
f=60;
Ref1=sin(2*pi*f*delT*sample);
Ref2=cos(2*pi*f*delT*sample);
A=[Vmachine Imachine Vinfbus Iinfbus Pmachine];
data1=A(:,1);
for count=1:length(data1)-length(sample)
Sumrealx=0;
Sumrealy=0;
for count1=1:length(sample)
Sumrealx=Sumrealx+data1(count+count1-1)*Ref1(count1);
Sumrealy=Sumrealy+data1(count+count1-1)*Ref2(count1);
end
Sumrealx=Sumrealx*2/length(sample);
Sumrealy=Sumrealy*2/length(sample);
Phmag(count)=sqrt(Sumrealx*Sumrealx+Sumrealy*Sumrealy);
Pang(count)=atan2(Sumrealy,Sumrealx)*180/pi;
end