cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

format command

ChuckI
1-Newbie

format command

I am trying to format a length into feet and inches, and am having trouble with the format command. I have the values of feet and inches calculated as integers and would like to combine them into a result as a text string.
6 REPLIES 6
StuartBruff
23-Emerald II
(To:ChuckI)

On 6/26/2009 3:22:58 PM, ucicrestengrg wrote:
== I am trying to format a length into feet and inches, and am having trouble with the format command. I have the values of feet and inches calculated as integers and would like to combine them into a result as a text string.

do you mean something like the attached?

Stuart

ftin(ft,in):=concat(num2str(ft)," ft ",num2str(in), " in")

Yes, I used something similar for a workaround. I was hoping somebody had a good example of the format command, as that would do it a little more cleanly.
Thanks
StuartBruff
23-Emerald II
(To:ChuckI)

On 6/26/2009 4:28:00 PM, ucicrestengrg wrote:
== Yes, I used something similar for a workaround. I was hoping somebody had a good example of the format command, as that would do it a little more cleanly.

Do you mean something like

ftin(ft,in):=format("{0} ft {1} in",ft,in)

?

Stuart

or just use format("{0} ft {1} in",12,3)

What about this one?

Luc

On 6/29/2009 5:17:26 PM, Luc_Meekes wrote:
== What about this one?

In my version of M14, 'format' must be renamed to something else, eg 'format2', otherwise it doesn't work - even changing the math style doesn't work.

Stuart

Top Tags