Got Questions? Get Answers.
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:
Display Matrix to GUI

Subject: Display Matrix to GUI

From: dine tiara

Date: 9 Jun, 2011 07:25:20

Message: 1 of 5

Dear all,
I would like to show the matrix like this
 0.5000 0.4028 0.3002 0.1917 0.0771 0.0437 0.1651 0.2926 0.4122
 0.5000 0.3629 0.2984 0.1935 0.0806 0.0403 0.1613 0.2823 0.4032
         0 1.0000 1.0000 1.0000 1.0000 1.0000 0 0 0
 0.5000 0.3629 0.2984 0.1935 0.0806 0.0403 0.1613 0.2823 0.4032

from a command window to GUI.

I was try this script
data_input=[[0.5;0.5;0;0.5] [0.40282664;0.362903226;1;0.362903226] [0.300158504;0.298387097;1;0.298387097] [0.191687708;0.193548387;1;0.193548387] [0.077073944;0.080645161;1;0.080645161] [0.043721018;0.040322581;1;0.040322581] [0.165105582;0.161290323;0;0.161290323] [0.292553108;0.282258065;0;0.282258065] [0.412202273;0.403225806;0;0.403225806] [0.5;0.5;0;0.5]]
myString = sprintf(' %s %d',data_input);
set(handles.text1, 'String', myString);

but the output not same with my purpose.
the output like this.
.000000e-0015.000000e-00105.000000e-0014.028266e-0013.629032e-00113.629032e-0013.001585e-0012.983871e-00112.983871e-0011.916877e-0011.935484e-00111.935484e-0017.707394e-0028.064516e-00218.064516e-0024.372102e-0024.032258e-00214.032258e-0021.651056e-0011.612903e-00101.612903e-0012.925531e-0012.822581e-00102.822581e-0014.122023e-0014.032258e-00104.032258e-0015.000000e-0015.000000e-00105.000000e-001

what should I do ???

Subject: Display Matrix to GUI

From: vedenev

Date: 9 Jun, 2011 07:48:01

Message: 2 of 5

In matlab text is cell array of strings. So you need in for loop
convert each row to string and put it cell of cell array. Then put
this cell array to 'string' property. There are also uitable control
to display/edit matricies.

------------------------------------
Maxim Vedenev, Matlab freelancer
vedenev@ngs.ru
http://simulations.narod.ru/

Subject: Display Matrix to GUI

From: Thomas Pieper

Date: 9 Jun, 2011 08:08:02

Message: 3 of 5

"dine tiara" <namaqtia@gmail.com> wrote in message <ispsh0$2a4$1@newscl01ah.mathworks.com>...
> Dear all,
> I would like to show the matrix like this
> 0.5000 0.4028 0.3002 0.1917 0.0771 0.0437 0.1651 0.2926 0.4122
> 0.5000 0.3629 0.2984 0.1935 0.0806 0.0403 0.1613 0.2823 0.4032
> 0 1.0000 1.0000 1.0000 1.0000 1.0000 0 0 0
> 0.5000 0.3629 0.2984 0.1935 0.0806 0.0403 0.1613 0.2823 0.4032
>
> from a command window to GUI.
>
> I was try this script
> data_input=[[0.5;0.5;0;0.5] [0.40282664;0.362903226;1;0.362903226] [0.300158504;0.298387097;1;0.298387097] [0.191687708;0.193548387;1;0.193548387] [0.077073944;0.080645161;1;0.080645161] [0.043721018;0.040322581;1;0.040322581] [0.165105582;0.161290323;0;0.161290323] [0.292553108;0.282258065;0;0.282258065] [0.412202273;0.403225806;0;0.403225806] [0.5;0.5;0;0.5]]
> myString = sprintf(' %s %d',data_input);
> set(handles.text1, 'String', myString);
>
> but the output not same with my purpose.
> the output like this.
> .000000e-0015.000000e-00105.000000e-0014.028266e-0013.629032e-00113.629032e-0013.001585e-0012.983871e-00112.983871e-0011.916877e-0011.935484e-00111.935484e-0017.707394e-0028.064516e-00218.064516e-0024.372102e-0024.032258e-00214.032258e-0021.651056e-0011.612903e-00101.612903e-0012.925531e-0012.822581e-00102.822581e-0014.122023e-0014.032258e-00104.032258e-0015.000000e-0015.000000e-00105.000000e-001
>
> what should I do ???

try

myString = sprintf('%.4f\t',data_input);

Subject: Display Matrix to GUI

From: dine tiara

Date: 16 Jun, 2011 06:57:04

Message: 4 of 5

"Thomas Pieper" <tom.pieper.nospam@t-online.de> wrote in message <ispv12$7vc$1@newscl01ah.mathworks.com>...
> "dine tiara" <namaqtia@gmail.com> wrote in message <ispsh0$2a4$1@newscl01ah.mathworks.com>...
> > Dear all,
> > I would like to show the matrix like this
> > 0.5000 0.4028 0.3002 0.1917 0.0771 0.0437 0.1651 0.2926 0.4122
> > 0.5000 0.3629 0.2984 0.1935 0.0806 0.0403 0.1613 0.2823 0.4032
> > 0 1.0000 1.0000 1.0000 1.0000 1.0000 0 0 0
> > 0.5000 0.3629 0.2984 0.1935 0.0806 0.0403 0.1613 0.2823 0.4032
> >
> > from a command window to GUI.
> >
> > I was try this script
> > data_input=[[0.5;0.5;0;0.5] [0.40282664;0.362903226;1;0.362903226] [0.300158504;0.298387097;1;0.298387097] [0.191687708;0.193548387;1;0.193548387] [0.077073944;0.080645161;1;0.080645161] [0.043721018;0.040322581;1;0.040322581] [0.165105582;0.161290323;0;0.161290323] [0.292553108;0.282258065;0;0.282258065] [0.412202273;0.403225806;0;0.403225806] [0.5;0.5;0;0.5]]
> > myString = sprintf(' %s %d',data_input);
> > set(handles.text1, 'String', myString);
> >
> > but the output not same with my purpose.
> > the output like this.
> > .000000e-0015.000000e-00105.000000e-0014.028266e-0013.629032e-00113.629032e-0013.001585e-0012.983871e-00112.983871e-0011.916877e-0011.935484e-00111.935484e-0017.707394e-0028.064516e-00218.064516e-0024.372102e-0024.032258e-00214.032258e-0021.651056e-0011.612903e-00101.612903e-0012.925531e-0012.822581e-00102.822581e-0014.122023e-0014.032258e-00104.032258e-0015.000000e-0015.000000e-00105.000000e-001
> >
> > what should I do ???
>
> try
>
> myString = sprintf('%.4f\t',data_input);


I was try ur script and the resume is true..but I wanna to display the matrix for 10 coloumn and 4 line like this:
0.5000 0.4028 0.3002 0.1917 0.0771 0.0437 0.1651 0.2926 0.4122
0.5000 0.3629 0.2984 0.1935 0.0806 0.0403 0.1613 0.2823 0.4032
0 1.0000 1.0000 1.0000 1.0000 1.0000 0 0 0
0.5000 0.3629 0.2984 0.1935 0.0806 0.0403 0.1613 0.2823 0.4032

. but it's just display in one line.
 so what the sintax?
please...

Subject: Display Matrix to GUI

From: Krishna Kumar

Date: 16 Jun, 2011 08:36:05

Message: 5 of 5

hi,
Try this
sprintf('%f %f %f %f %f %f %f %f %f %f \n',data_input')
This will give you the output you want.
To automize this for m x n matrix,
c=[ %f %f ........% concatenate as many times and put \n at end
sprintf(c,data_input').
Note the transpose!
hth,
Krishna

Tags for this Thread

No tags are associated with 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