From: Ashish Uthama on
On Sat, 06 Feb 2010 00:00:06 -0500, Frank Bieniek <frankiemets(a)yahoo.com>
wrote:

> Ok we have a project due where we are suppost to make the line say this,
> after we import a apple file into matlab. It is suppost to say this
> "&#8220;This stock's highest ever closing price was $215.04, which
> occurred on 19-Jan-10&#8221; When i try tho I get this fprintf('This
> stocks highest ever closing price was %.2f has which occurred on
> 19-Jan-10.\n', name, x)
> This stocks highest ever closing price was 72.00 has which occurred on
> 19-Jan-10.
> This stocks highest ever closing price was 105.00 has which occurred on
> 19-Jan-10.
> This stocks highest ever closing price was 103.00 has which occurred on
> 19-Jan-10.
> This stocks highest ever closing price was 104.00 has which occurred on
> 19-Jan-10.
> This stocks highest ever closing price was 101.00 has which occurred on
> 19-Jan-10.
> This stocks highest ever closing price was 115.00 has which occurred on
> 19-Jan-10.
> This stocks highest ever closing price was 116.00 has which occurred on
> 19-Jan-10.
> This stocks highest ever closing price was 32.00 has which occurred on
> 19-Jan-10.
> This stocks highest ever closing price was 112.00 has which occurred on
> 19-Jan-10.
> This stocks highest ever closing price was 114.00 has which occurred on
> 19-Jan-10.
> This stocks highest ever closing price was 105.00 has which occurred on
> 19-Jan-10.
> This stocks highest ever closing price was 99.00 has which occurred on
> 19-Jan-10.
> This stocks highest ever closing price was 101.00 has which occurred on
> 19-Jan-10.
> This stocks highest ever closing price was 215.04 has which occurred on
> 19-Jan-10.
>
> For some reason it puts in all these lins instead of it saying 215.04
> ... I am bad at Matlab any help is greatly appreciated

type 'whos' into your command window.
Notice that x is an array of price values, not a single value.
fprintf prints one line for each element in x, thats why you see 'all
these lines'
Search the doc to find a function which takes an array as an input and
returns one single max value, use this in place of x
From: Ashish Uthama on
On Sat, 06 Feb 2010 16:21:27 -0500, Ashish Uthama
<first.last(a)mathworks.com> wrote:

> On Sat, 06 Feb 2010 00:00:06 -0500, Frank Bieniek
> <frankiemets(a)yahoo.com> wrote:
>
>> Ok we have a project due where we are suppost to make the line say
>> this, after we import a apple file into matlab. It is suppost to say
>> this "&#8220;This stock's highest ever closing price was $215.04, which
>> occurred on 19-Jan-10&#8221; When i try tho I get this fprintf('This
>> stocks highest ever closing price was %.2f has which occurred on
>> 19-Jan-10.\n', name, x)
>> This stocks highest ever closing price was 72.00 has which occurred on
>> 19-Jan-10.
>> This stocks highest ever closing price was 105.00 has which occurred on
>> 19-Jan-10.
>> This stocks highest ever closing price was 103.00 has which occurred on
>> 19-Jan-10.
>> This stocks highest ever closing price was 104.00 has which occurred on
>> 19-Jan-10.
>> This stocks highest ever closing price was 101.00 has which occurred on
>> 19-Jan-10.
>> This stocks highest ever closing price was 115.00 has which occurred on
>> 19-Jan-10.
>> This stocks highest ever closing price was 116.00 has which occurred on
>> 19-Jan-10.
>> This stocks highest ever closing price was 32.00 has which occurred on
>> 19-Jan-10.
>> This stocks highest ever closing price was 112.00 has which occurred on
>> 19-Jan-10.
>> This stocks highest ever closing price was 114.00 has which occurred on
>> 19-Jan-10.
>> This stocks highest ever closing price was 105.00 has which occurred on
>> 19-Jan-10.
>> This stocks highest ever closing price was 99.00 has which occurred on
>> 19-Jan-10.
>> This stocks highest ever closing price was 101.00 has which occurred on
>> 19-Jan-10.
>> This stocks highest ever closing price was 215.04 has which occurred on
>> 19-Jan-10.
>>
>> For some reason it puts in all these lins instead of it saying 215.04
>> ... I am bad at Matlab any help is greatly appreciated
>
> type 'whos' into your command window.
> Notice that x is an array of price values, not a single value.
> fprintf prints one line for each element in x, thats why you see 'all
> these lines'
> Search the doc to find a function which takes an array as an input and
> returns one single max value, use this in place of x

my bad, as replied in your other thread: The symptoms are similar to what
I explained above, but the issue is with the variable name being used as
an array of values for %.2f.