VC++对瑞利衰弱仿真

来源:百度知道 编辑:UC知道 时间:2024/05/30 15:24:57
% Program 2-5
% fade.m
%
% Generate Rayleigh fading
%
function [iout,qout,ramp,rcos,rsin]=fade(idata,qdata,...
nsamp,tstp,fd,no,counter,flat)
%********************** variables *********************
% idata : input Ich data
% qdata : input Qch data
% iout : output Ich data
% qout : output Qch data
% ramp : Amplitude contaminated by fading
% rcos : Cosine value contaminated by fading
% rsin : Cosine value contaminated by fading
% nsamp : Number of samples to be simulated
% tstp : Minimum time resolution
% fd : maximum doppler frequency
% no : number of waves in order to generate fading
% counter : fading counter
% flat : flat fading or not
% (1-flat (only amplitude is fluctuated),0-normal
% (phase and amplitude are fluctutated))
%******************************************************
if fd ~= 0.0
ac0 = sqrt(1.0 ./ (2.0.*(no + 1)));
% power normaliz

#include <iostream>
#include <fstream>
#include <string>

using namespace std;
int GetStudentMark(ifstream &fin,string name[],float mark[])
{
int n = 0;
while((n<50) && (fin>>name[n]) && (fin>>mark[n++]))
{
cout<<name[n-1]<<" got "<<mark[n-1]<<endl;
}
return n;
}

int TopMark(float mark[],int n)
{
float maxmark = 0;
int maxi = -1;

for(int i=0; i< n; ++i){
if(mark[i] > maxmark){
maxmark = mark[i];
maxi = i;
}
}
return maxi;
}

int main()
{
ifstream fin;
string name[50];
float mark[50];
int maxmark=0.0;
int n;

fin.open("Marks.txt");
if (!fin){
cout<<"could not open file marks.txt...bye!";
exit(1);
}

n = GetStudentMark(fin,name,mark);