How can I do the same job that the simulink block "Byte Unpack" but in matlab not with simulink
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Alexis Artuso
il 22 Giu 2016
Commentato: Alexis Artuso
il 27 Giu 2016
Hi everyone,
I'm looking for functions in matlab or different ways to create a function which can do the same job that the simulink block "Byte Unpack".
I'm trying to unpack the input data message(uint8) to the unpacked output message (single) with 6 output ports dimension (See picture). But in my case I don't want to use simulink, only matlab code. The input data message come from to :
Receiver = dsp.UDPReceiver('LocalIPPort',8080,'RemoteIPAddress','192.168.102.111',...
'ReceiveBufferSize',24,'MaximumMessageLength',24,'MessageDataType','uint8');
DATAReceived = step(Receiver);
Any ideas? or suggestions?
Thanks,
Alexis
0 Commenti
Risposta accettata
Steven Lord
il 22 Giu 2016
I think some combination of typecast and swapbytes will get you close to what you want.
3 Commenti
Steven Lord
il 22 Giu 2016
You want to know how to get 6 single precision numbers from typecast? Pass in a vector of 24 int8 values.
s = single(1:6)
in = typecast(s, 'int8')
s2 = typecast(in, 'single')
Take a look at the values in s and in with the display format set to "format hex" and you should see how they're related. You can also experiment with swapbytes on s and how that affects the values stored in in.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Prepare Model Inputs and Outputs in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!