Matlab fprint with strings

Status
Not open for further replies.
Hopefully someone here uses matlab (or Octave / SciLab variants) more than I. Have not used matlab since 1994.

My script is:
Text = ["V1";"V2";"V0";"I1";"I2";"I0";"Z1";"Z2";"Z0"];
formatSpec = "%s = \n";
for row = 1:9
fprintf(formatSpec,(Text(row)));
endfor

My output is:
V =
V =
V =
I =
I =
I =
Z =
Z =
Z =

Why are the numbers not following???
 
I never saw MATLAB.

Looking-up formatSpec gave me this:
Format data into string - MATLAB sprintf

Notable Behavior of Conversions with Formatting Operators
....
If you apply a text conversion (either %c or %s) to integer values, MATLAB converts values that correspond to valid character codes to characters.
Example: '%s' converts [65 66 67] to ABC.


0 to 2 would be non-printing characters. This might be checked by %s 65 66 67 to see if you get A B C.

HOWever above that it says that double-quote makes a string, so my expectation would be that "V1" should be taken literal, not interpreted.
 
Status
Not open for further replies.