<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: complex to byte array in LabVIEW MathScript RT Module</title>
    <link>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1473452#M1237</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cut/paste issue on the original:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;bytes = [swapbytes(typecast(real(cSingle),&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;'uint8'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;)) ...&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;swapbytes(typecast(imag(cSingle),&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;'uint8'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;))];&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Mar 2011 18:14:04 GMT</pubDate>
    <dc:creator>ARGold</dc:creator>
    <dc:date>2011-03-03T18:14:04Z</dc:date>
    <item>
      <title>complex to byte array</title>
      <link>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1473234#M1236</link>
      <description>&lt;P&gt;I need to convert a complex single to a byte array for transmission via ethernet packet (with the inclusion of a checksum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In Matlab:&amp;nbsp; you can use the following to get a byte array from a complex single:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;
&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;cSingle = single(.1234+i*.3456);&lt;/P&gt;
&lt;P&gt;bytes = [swapbytes(typecast(real(cSingle),&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; swapbytes(typecast(imag(cSingle),&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;'uint8'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;))];&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mathscript does not support the typecast or swapbytes functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So how can I convert the complex single to a byte array?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks:&lt;/P&gt;
&lt;P&gt;ARGOLD&lt;/P&gt;
&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;'uint8'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;)) ...&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2011 15:58:18 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1473234#M1236</guid>
      <dc:creator>ARGold</dc:creator>
      <dc:date>2011-03-03T15:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: complex to byte array</title>
      <link>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1473452#M1237</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cut/paste issue on the original:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;bytes = [swapbytes(typecast(real(cSingle),&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;'uint8'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;)) ...&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;swapbytes(typecast(imag(cSingle),&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;&lt;FONT face="Courier New" size="2" color="#a020f0"&gt;'uint8'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;))];&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2011 18:14:04 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1473452#M1237</guid>
      <dc:creator>ARGold</dc:creator>
      <dc:date>2011-03-03T18:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: complex to byte array</title>
      <link>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1474966#M1238</link>
      <description>&lt;P&gt;Do you really need to do this in MathScript? Seems much easier in plain LabVIEW. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2011 19:08:51 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1474966#M1238</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2011-03-04T19:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: complex to byte array</title>
      <link>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1475138#M1239</link>
      <description>&lt;P&gt;Yes I need to do this in mathscript.&amp;nbsp; It is a small part of a bigger function and needs to be done in several places.&amp;nbsp; It would be silly to break the function up into multiple v.i.'s.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is also easy to do in MatLab (as shown above) so why should it not be just as easy to do in mathscrtipt?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you come right down to it, are we not just reading the hex bytes out of the memory?&amp;nbsp; The only real issue is to swap bytes or not to swap bytes.&amp;nbsp; That should be easy in any event.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cordially,&lt;/P&gt;
&lt;P&gt;ARGold&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2011 20:58:53 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1475138#M1239</guid>
      <dc:creator>ARGold</dc:creator>
      <dc:date>2011-03-04T20:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: complex to byte array</title>
      <link>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1478322#M1240</link>
      <description>&lt;P data-unlink="true"&gt;Hey ARGold,&lt;BR /&gt;&lt;BR /&gt;Please take a look at this list of functions if you have not already: LabVIEW MathScript Function List. This is the list of all functions we can perform in mathscript.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 17:53:19 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1478322#M1240</guid>
      <dc:creator>Ricky_V.</dc:creator>
      <dc:date>2025-08-05T17:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: complex to byte array</title>
      <link>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1478362#M1241</link>
      <description>&lt;P&gt;I have searched through the function list and do not see how to solve this particular problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need more specific help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cordailly,&lt;/P&gt;
&lt;P&gt;ARGold&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2011 16:38:42 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1478362#M1241</guid>
      <dc:creator>ARGold</dc:creator>
      <dc:date>2011-03-08T16:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: complex to byte array</title>
      <link>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1480532#M1242</link>
      <description>&lt;P&gt;You could possibly try and write the function yourself if the function isn't supported.&amp;nbsp; This might be more difficult, but if you absolutely cannot step outside of your mathscript to do the conversion, then this might be necessary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-unlink="true"&gt;http://zone.ni.com/reference/en-XX/help/371361B-01/lvhowto/defining_mathscript_functions/&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jon S&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 17:53:35 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1480532#M1242</guid>
      <dc:creator>Jonathan_S1</dc:creator>
      <dc:date>2025-08-05T17:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: complex to byte array</title>
      <link>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1480596#M1243</link>
      <description>&lt;P&gt;Thanks Again Jon:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your replies so far have been "mathscript 101".&amp;nbsp;&amp;nbsp; The last reply is too general and high level to do anything with and common knowledge to all but the most novice of mathscript/matlab coders.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I do need is more information about what is happening under the hood in the bits and bytes world of mathscript "classes"&amp;nbsp; (the term used by matlab to define all the data types).&amp;nbsp; This should be a relatively simple operation of&amp;nbsp;extracting, byte by byte, the raw data from a given type (double, complex, single, etc.) and creating a byte array.&amp;nbsp; I need to know the specific instruction(s) to extract the bytes from the data type. Once done, the swapping operation should be easy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having written the above, here is a question you might be able to answer:&amp;nbsp; Can mathscript "call" a VI?&amp;nbsp; If so, I could write the function in labview and call it (repeatly) from mathscript...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cordially,&lt;/P&gt;
&lt;P&gt;ARGold&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2011 22:27:53 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1480596#M1243</guid>
      <dc:creator>ARGold</dc:creator>
      <dc:date>2011-03-09T22:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: complex to byte array</title>
      <link>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1480610#M1244</link>
      <description>&lt;P&gt;Sorry Jon:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It wasn't you replying earlier...&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2011 22:39:27 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW-MathScript-RT-Module/complex-to-byte-array/m-p/1480610#M1244</guid>
      <dc:creator>ARGold</dc:creator>
      <dc:date>2011-03-09T22:39:27Z</dc:date>
    </item>
  </channel>
</rss>

