Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to answer in matrix form?

Subject: How to answer in matrix form?

From: J K

Date: 28 May, 2013 04:16:11

Message: 1 of 3

I have the output, which consists of 51 temperature at 51 nodes.

http://www.flickr.com/photos/94031835@N02/8862423679/

The link provided give you the idea what I'm talking about. How to use fprintf so that the output given can identify the temperature of each node?

Something like this:
T1 = 85.7929
T2 = 85.5476
..... so on

Thank you

Subject: How to answer in matrix form?

From: Nasser M. Abbasi

Date: 28 May, 2013 07:28:13

Message: 2 of 3

On 5/27/2013 11:16 PM, J K wrote:
> I have the output, which consists of 51 temperature at 51 nodes.
>
> http://www.flickr.com/photos/94031835@N02/8862423679/
>
> The link provided give you the idea what I'm talking about.
>How to use fprintf so that the output given can identify the temperature of each node?
>
> Something like this:
> T1 = 85.7929
> T2 = 85.5476
> ..... so on
>

may be

--------------------
EDU>> A=rand(5,1);
EDU>> f=@(i) fprintf('A%d = %f\n',i,A(i))
EDU>> arrayfun(@(i) f(i),1:length(A))
---------------------
A1 = 0.097540
A2 = 0.278498
A3 = 0.546882
A4 = 0.957507
A5 = 0.964889

Subject: How to answer in matrix form?

From: Steven_Lord

Date: 28 May, 2013 14:29:01

Message: 3 of 3



"Nasser M. Abbasi" <nma@12000.org> wrote in message
news:ko1mab$uh1$1@speranza.aioe.org...
> On 5/27/2013 11:16 PM, J K wrote:
>> I have the output, which consists of 51 temperature at 51 nodes.
>>
>> http://www.flickr.com/photos/94031835@N02/8862423679/
>>
>> The link provided give you the idea what I'm talking about.
>>How to use fprintf so that the output given can identify the temperature
>>of each node?
>>
>> Something like this:
>> T1 = 85.7929
>> T2 = 85.5476
>> ..... so on
>>
>
> may be
>
> --------------------
> EDU>> A=rand(5,1);
> EDU>> f=@(i) fprintf('A%d = %f\n',i,A(i))
> EDU>> arrayfun(@(i) f(i),1:length(A))
> ---------------------
> A1 = 0.097540
> A2 = 0.278498
> A3 = 0.546882
> A4 = 0.957507
> A5 = 0.964889

There's no need for ARRAYFUN in this case, since FPRINTF is vectorized.

>> d = (1:10).';
>> x = sqrt(d);
>> fprintf('x%d = %f\n', [d x].')
x1 = 1.000000
x2 = 1.414214
x3 = 1.732051
x4 = 2.000000
x5 = 2.236068
x6 = 2.449490
x7 = 2.645751
x8 = 2.828427
x9 = 3.000000
x10 = 3.162278

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us