How can I use simulink to merge four elements in a matrix to become just one symbol?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have tried using the embedded matlab function, but ended up gettin the error "Subscripting into an mxArray is not supported"
For example, assuming I'm receiving a 12x1 matrix element from a simulink block [1;2;3;4;5;6;7;8], I want simulink to group the first 4 elements and merge or symbolise it as 1234(i.e a single integer), and carry on like that for the next 4 elements. I.e, 5678 for the next set.
Here is what I vae put inside the embedded function: %---------------------------------------------------------- function y = fcn(u) formatSpec = '%d%d%d%d' A=0;A=length(u); y = (zeros(length(u),4,'double'));%y=yy; coder.extrinsic('sprintf','str2double'); u=str2double(u);
for n=1:4:A y=sprintf(formatSpec,u(n), u(n+1), u(n+2), u(n+3)); %y=[y yy]; end %------------------------------------------------------------
Anyone with the idea should please bail me out. Regards, Ken
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Simulink Functions 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!