To download NI software, including the products shown below, visit ni.com/downloads.
Overview: The VI converts the string format with complex numbers to complex number format.
Description:
Takes a string input in one of the following formats:
x+iy; -x+iy; x-iy; -x-iy; x+jy; -x+jy; x-jy; -x-jy;
where x and y are numbers.
The VI then splits the sting into three strings: the real part (including the middle operator), the i or j, and complex part. Next, the "+" or "-" case is selected by extracting the last element of the string containing the real part. The extraction is done by determining the length-1 of the string and making this value the offset for String Subset, which leaves just the operator as the substring for the case selector. Inside the cases, the string are converted to double precision numbers and combined into a complex number. The "-" case converts the complex part to a negaitve number by subtracting it from zero.
Steps to Implement or Execute Code:
1. Insert string input.
2. Run the VI.
3, Write down the result from Complex Number.
Additional Information or References:
The user needs to select whether "i" or "j" is used when writing the complex number.
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
I'm not sure why the author felt it necessary to change the format from the standard LabVIEW format of "a+bi" to "a+ib". Wolfram?
Shown below is a simple VI that uses the "a+bi" that LabVIEW uses.