フィルターのクリア

Can you give me an example about writing file by the memmapfile function ? think you very much.

2 ビュー (過去 30 日間)
deng
deng 2016 年 7 月 4 日
編集済み: Stephen23 2016 年 7 月 4 日
Can you give me an example about writing file by the memmapfile function ? think you very much.
  2 件のコメント
Stephen23
Stephen23 2016 年 7 月 4 日
編集済み: Stephen23 2016 年 7 月 4 日
@deng: the memmapfile already includes full working examples... why not have a look at them ?
@José-Luis: maybe you should tell MATLAB this, because the memmapfile help page clearly says "accelerating file reading and writing". And the optional argument 'Writable' would indicate that the file can be writable...
José-Luis
José-Luis 2016 年 7 月 4 日
Sorry about that. Got confused. Coffee time.

サインインしてコメントする。

回答 (1 件)

Stephen23
Stephen23 2016 年 7 月 4 日
編集済み: Stephen23 2016 年 7 月 4 日
Here is the first example from the memmapfile documentation, with one change: the addition of the 'writable' option:
>> myData = uint8(1:10)';
>> fileID = fopen('records.dat','wt');
>> fwrite(fileID, myData,'uint8');
>> fclose(fileID);
>> m = memmapfile('records.dat','writable',true); % <- add "writable" option
>> m.Data % check data
ans =
1
2
3
4
5
6
7
8
9
13
10
And we can write to that file very simply:
>> m.Data(3) = 255; % write a new value for third element
>> m.Data % check data
ans =
1
2
255
4
5
6
7
8
9
13
10
>>
That is all... you can simply treat the m object as a structure, and the Data array as an Array, accessing the elements as you wish. Read the docs for more information.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by