mxArray problem

조회 수: 12 (최근 30일)
dimitris
dimitris 2011년 11월 1일
In a simulink model I use a matlab function block in which i open a file(fopen), read some numbers(fscanf) and put them in an array.Then i close the file. The problem is that when i try to access the elements of the array, for example write ARRAY(1), i get the following error : "Subscripting into an mxArray is not supported."
How i will be able to have access to this array?

채택된 답변

Kaustubha Govind
Kaustubha Govind 2011년 11월 1일

추가 답변 (2개)

Rajaram B S R
Rajaram B S R 2011년 11월 1일
I think the problem is,
1) Data read from the file is of type mxArray and, 2) In the mex function (C coding mode) you are trying to access the contents directly.
For subscripting to be possible, you need to copy it into a local dynamically allocated array and then extract the data using mxGetChars or mxGetPr depending on the data in the file.
  댓글 수: 1
dimitris
dimitris 2011년 11월 1일
I did not make it clear but i am writing matlab code and not C but thank you for your response.

댓글을 달려면 로그인하십시오.


Kristian Vepsäläinen
Kristian Vepsäläinen 2013년 7월 31일
편집: Kristian Vepsäläinen 2013년 7월 31일
I have simulink file model where I use matlab function block and there is code:
function sovitus=f(x1,x2,x3,x4,x5)
coder.extrinsic('smooth');
x=[x1 x2 x3 x4 x5];
apu=smooth(x,'sgolay');
sovitus=apu(1);
I have tried use foo(apu(1)) but it don't work. Error is Subscripting into an mxArray is not supported. What I should to do?
  댓글 수: 1
Kaustubha Govind
Kaustubha Govind 2013년 7월 31일
Did you follow the solution linked in my answer? You need to pre-allocate the variable apu.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by