Matlab相关概念和技巧(不断更新…)

01/29/2015  |  03:53分类:物理  |  标签:  |  2,523 views

概念:

1. .mat和.bin格式的文件有什么区别?

.bin 就是常见的二进制文件,通俗的说,就是以计算机能够接受的二进制0, 1序列来存放的文件,任何数据都可以二进制文件来存储,比如:文字、数字、图像等。如果你想查看这些二进制序列,可以用UltraEdit编辑 .mat是matlab特有的一种文件格式,用于保存workspace变量

2. data type:

A ULONG_PTR  is an unsigned long type used for pointer precision
doublePtr????

技巧:

// save(filename, ‘f’,’z’, ‘-mat’)~save(‘filename.mat’,’f’,’z’)
// datestr(now,30): get the current date and time
// a=[1 2; 3 4] then mean(a,2)=[1.5;3.5]
// plot([0,1+i]); draw a line from (0,0) to (1,1)
// text文本换行我用的是:fprintf(fid,’\r\n’,str(i,:));

 

*What is the difference between phase and angle:
At first, ANGLE command is from MATLAB core, PHASE from system identification toolbox.
ANGLE command always give result in range [-pi, pi].
PHASE command is more complex. If you have two adjacent points in input vector with phase near pi, for example
X=[-1+0.1i -1-0.1i]
phase(X) command will give answer greater than pi for the second value (difference between phases values should be less than pi).
At this time angle(X) command will give value near -pi for the second argument (wrap values into range [-pi, pi]).
e.g.,
phase(X)= 3.041924001098631 3.241261306080955
angle(X)= 3.041924001098631 -3.041924001098631
phase(X(2))= -3.041924001098631

*DAQmx Timing and Sample Rates :
http://digital.ni.com/public.nsf/allkb/3E3D74E26B8A5B83862575CA0053E4B5

int32 DAQmxCfgSampClkTiming (TaskHandle taskHandle, const char source[], float64 rate, int32 activeEdge, int32 sampleMode, uInt64 sampsPerChanToAcquire);
sampsPerChanToAcquire: uInt64 The number of samples to acquire or generate for each channel in the task if sampleMode is DAQmx_Val_FiniteSamps. If sampleMode is DAQmx_Val_ContSamps, NI-DAQmx uses this value to determine the buffer size.

int32 DAQmxReadAnalogF64 (TaskHandle taskHandle, int32 numSampsPerChan, float64 timeout, bool32 fillMode, float64 readArray[], uInt32 arraySizeInSamps, int32 *sampsPerChanRead, bool32 *reserved);
numSampsPerChan: If Number of Samples Per Channel is -1 or unwired while the acquisition mode is Finite (acquisition mode is an input for the DAQmx Timing VI), then the DAQmx Read VI wait until all the samples in the finite acquisition are in the PC buffer and then reads them in. If the acquisition mode is continuous, then all the samples currently available in the PC buffer are read

结论: When determining the how fast your data will be acquired, keep in mind that both steps in the acquisition must agree.  The rate at which the data is transferred from the hardware FIFO to the PC buffer must not be too fast or too slow compared to the rate at which the data is being loaded into the hardware FIFO itself.  If it is too fast or too slow, a PC buffer error will be thrown.

How is the buffer size determined?
http://zone.ni.com/reference/en-XX/help/370466V-01/mxcncpts/buffersize/

*How to scale a polar plot?
http://in.mathworks.com/matlabcentral/newsreader/view_thread/5301
I found a nice trick:
Place a point at e.g. pi / (max. value) and the plot scales to this
value. Now add your traces:
figure;
polar(pi, 5);
hold on;
polar….


发表您的评论