Why do the functions fread and fwrite take so long to run in Matlab?
古いコメントを表示
Hi,
I am working on reading and writing data to a piece of hardware from Matlab. Time is an issue for me. I was running a Matlab code that uses the functions fread and fwrite. Using profile report, I saw that these functions take quite a long time. I was wondering what type of stuff are happening under the hood when I call fread and fwrite that are making it take so long. FYI, I am using fread and fwrite to read and write to the COM port.
Thanks in advance, David
2 件のコメント
Walter Roberson
2013 年 6 月 27 日
How much data at a time are you fwrite() ? Is the COM port a USB device emulating a serial port?
David
2013 年 6 月 28 日
採用された回答
その他の回答 (1 件)
Ravi
2013 年 6 月 28 日
Why cant you use S-functions & i am reading some 1 lakh data line or values within seconds.... Firstly you send your code & what u have done till now.. Then we can discuss further..
static void mdlOutputs(SimStruct *S, int_T tid) { //get pointer to the block's output signal real_T *y = ssGetOutputPortSignal(S,0);
/*get pointer to array of pointers, where the first element is the address
*of the open file */
void** pwork = ssGetPWork(S);
/*read a floating point number and then the comma delimiter
*store the result in y*/
fscanf(pwork[0],"%f%*c",y);
}
we used such type of code.... So u describe ur code....
カテゴリ
ヘルプ センター および File Exchange で Instrument Control Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!