error in matlab function block

  • Item one
  • Item twoi am using a 'matlab function' block i write the code to map a file to memory using this instructions
filename = fullfile(tempdir, 'talk_answer.dat');
m = memmapfile(filename, 'Writable', true, 'Format', 'double');
j=m.data(1:5);
i have an error in "j=m.data(1:5);" this error appears " Attempt to extract field 'data' from 'mxArray'. Function 'MATLAB Function' (#23.1222.1223), line 43, column 4: "m" Launch diagnostic report."
what can i do to avoid this error

댓글 수: 3

Prior to executing the line j=m.data(1:5), type the following in the Command Window
disp(m)
What is written to the console? Please paste the results to a comment. As well, please include your version of MATLAB.
wael taie
wael taie 2014년 8월 21일
편집: wael taie 2014년 8월 21일
m = Filename: 'C:\Users\WAEL_T~1\AppData\Local\Temp\talk_answer.dat'
Writable: true
Offset: 0
Format: 'double'
Repeat: Inf
Data: 32x1 double array
my matlab version :R2012b.(8.0.0.783) win64
Geoff Hayes
Geoff Hayes 2014년 8월 21일
편집: Geoff Hayes 2014년 8월 21일
What happens if you just run the following test code
myData = double(1:10)';
filename = fullfile(pwd, 'records.dat');
fileID = fopen(filename,'w');
fwrite(fileID, myData,'double');
fclose(fileID);
testVar = memmapfile(filename, 'Writable', true, 'Format', 'double');
k=testVar.data(1:5);
It will create a small file and then execute the same commands as before.
Also, type
which m -all
I am just curious if your choice of variable name m is conflicting with something else.

답변 (0개)

이 질문은 마감되었습니다.

태그

질문:

2014년 8월 20일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by