原创 ITPP + Matlab

2010-7-2 15:41 2479 6 6 分类: 工程师职场

  As we all know, ITPP have no functions which could draw some pictures, so, after the simulation simulated by ITPP, we have to show our data by some other tools.

    Using Matlab to show your data is a good method.

1. Use the ITPP to get the data.

2. Save your data to files.

   Using the class named "it_file" and the operater "<<" to save your data to files.

3. Get the data in Matlab.

   Firstly, you should make sure that the folder $PREFIX/share/itpp is included your Matlab/Octave path variable ($PREFIX is the IT++ installation prefix: /usr/local by default). Using "path" command to set the path. Note that, in different version of ITPP, the path may be different, so you should find out the right path. As a example, in my computer, the path of the "share file path" is "..\itpp-4.0.1\extras".

   After that you could use the function "itload" to open the file and to get the data you saved.

4. Using Matlab function to show the data.

   That all.

   The following is one program from ITPP webset. Have a try with it.

   Firstly, run the program in your Studio.

#include <itpp/itcomm.h>

 

using namespace itpp;

 

int main()

{

  // Declare my_channel variable as an instance of the Rayleigh_Channel

  // class

  TDL_Channel my_channel;

 

  // The normalized Doppler frequency is set to 0.1

  double norm_dopp = 0.1;

  my_channel.set_norm_doppler(norm_dopp);

 

  // Generate nrof_samples of the fading process and store them in ch_coeffs

  // matrix

  int nrof_samples = 10000;

  cmat ch_coeffs;

  my_channel.generate(nrof_samples, ch_coeffs);

 

  // Open an output file "rayleigh_test.it"

  it_file ff("rayleigh_test.it");

 

  // Save channel coefficients to the output file

  ff << Name("ch_coeffs") << ch_coeffs;

 

  // Close the output file

  ff.close();

 

  // Exit program

  return 0;

}

   Secondly, use the data file "rayleigh_test.it" in the Matlab.

   Follow this:

itload('rayleigh_test.it');

figure(1); clf;

semilogy(abs(ch_coeffs(1:200)))

 

Done!
PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
6
关闭 站长推荐上一条 /3 下一条