[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: Arrays of strings

**From**: |
niles |

**Subject**: |
Re: Arrays of strings |

**Date**: |
Sun, 03 Sep 95 16:45:28 -0400 |

jwe writes:
>*It's not pretty, but you can do this:*
>
>* s = toascii (s); s = setstr (s (INDEX));*
Yeah I hadn't thought of this, actually very useful!
Here's what I did I wrote a tiny function stostr:
function var = stostr(var, loc, string)
var(loc,1:max(size(toascii(string)))) = toascii(string);
Now, in an m-file you can to things like..
states = 0;
k=1;
states = stostr(states,k++,"Beta, Side Silp Angle (Degrees)");
states = stostr(states,k++,"r, Yaw Rate (Degrees/sec)");
states = stostr(states,k++,"p, Roll Rate (Degrees/sec)");
states = stostr(states,k++,"Phi, Roll Angle (Degrees)");
states = stostr(states,k++,"Psi, Yaw Angle (Degrees)");
states = stostr(states,k++,"w, Wind Angle (Degrees)");
--------------------------
then later:
for k = 1:6 % States
ylabel(setstr(states(k,:)))
plot(t,x(:,k))
end
----------------------
thought others might find this useful...
Thanks for the idea!
Rick.