フィルターのクリア

Creating a .bin file in workspace?

14 ビュー (過去 30 日間)
Roman Around
Roman Around 2023 年 6 月 26 日
回答済み: Deepak 2023 年 6 月 26 日
I have to pass a .bin file to a MEX c function (zlib decompression) and I currently write to my temp folder, but I was wondering if I could create a .bin file in the workspace somehow.
By housing everything there I think I could run a parallel for loop allowing me to execute things faster.

回答 (1 件)

Deepak
Deepak 2023 年 6 月 26 日
Yes, in MATLAB, you can create a .bin file in the workspace using the `fwrite` function. Here's an example of how you can accomplish this:
% Generate some data to write to the .bin file
data = rand(1, 1000);
% Create a file in the workspace directory
filename = 'data.bin';
fileID = fopen(filename, 'w');
% Write the data to the file
fwrite(fileID, data, 'double');
% Close the file
fclose(fileID);
In this example, `data` is an array of random numbers generated using the `rand` function. The `fwrite` function is then used to write the data to the file specified by `filename`. The `'double'` argument specifies the data type to be written.
You can modify this code to suit your specific needs. Once you have created the .bin file in the workspace, you can pass it to your MEX C function for zlib decompression. Remember to adjust the file path accordingly when calling your MEX function.

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by