mxArray problem
33 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponse acceptée
Kaustubha Govind
le 1 Nov 2011
Please see the answer here: http://www.mathworks.com/matlabcentral/answers/13297-subscripting-into-an-mxarray
0 commentaires
Plus de réponses (2)
Rajaram B S R
le 1 Nov 2011
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.
Kristian Vepsäläinen
le 31 Juil 2013
Modifié(e) : Kristian Vepsäläinen
le 31 Juil 2013
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 commentaire
Kaustubha Govind
le 31 Juil 2013
Did you follow the solution linked in my answer? You need to pre-allocate the variable apu.
Voir également
Catégories
En savoir plus sur Naming Conventions dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!