From: Ashwin on
The classregtree function returns a tree object. I am unable to find a method that can write to a simple text file the tree description.
From: Steven_Lord on


"Ashwin " <m_ashwin_81(a)yahoo.com> wrote in message
news:i24h0g$13$1(a)fred.mathworks.com...
> The classregtree function returns a tree object. I am unable to find a
> method that can write to a simple text file the tree description.

If you're looking to write to the file the description that is displayed
when you type the name of the tree variable at the prompt, then use EVALC to
capture that displayed output and write that string to a file.

If you mean something different when you refer to "the tree description"
then please clarify what specifically you mean by that phrase.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: Ashwin on
Steven,

Thanks for replying. In my code, I end up with a pruned tree, tmin. It looks like this when I query it at the command prompt:

>> tmin

tmin =

Decision tree for classification
1 if X<0.768118 then node 2 else node 3
2 if Y<-0.168118 then node 4 else node 5
3 class = 0
4 class = 0
5 if Y<0.525419 then node 6 else node 7
6 if Yaw<-44.7976 then node 8 else node 9
7 class = 0
8 class = 0
9 if Yaw<-9.0949 then node 10 else node 11
10 if Z<0.958524 then node 12 else node 13
11 if Yaw<44.8521 then node 14 else node 15
12 class = 0
13 if Z<1.7442 then node 16 else node 17
14 class = 0
15 if Yaw<71.1694 then node 18 else node 19
16 class = 1
17 class = 0
18 class = 1
19 class = 0

My question is how do I stream this if...else text data into a .txt file. EVALC did not seem to help. At least it was not obvious to me. T=evalc(tmin) did not work as didn't
T=evalc(tmin.disp) or T=evalc(tmin.display)

"Steven_Lord" <slord(a)mathworks.com> wrote in message <i24lcu$h7f$1(a)fred.mathworks.com>...
>
>
> "Ashwin " <m_ashwin_81(a)yahoo.com> wrote in message
> news:i24h0g$13$1(a)fred.mathworks.com...
> > The classregtree function returns a tree object. I am unable to find a
> > method that can write to a simple text file the tree description.
>
> If you're looking to write to the file the description that is displayed
> when you type the name of the tree variable at the prompt, then use EVALC to
> capture that displayed output and write that string to a file.
>
> If you mean something different when you refer to "the tree description"
> then please clarify what specifically you mean by that phrase.
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
From: Steven_Lord on


"Ashwin " <m_ashwin_81(a)yahoo.com> wrote in message
news:i24o1v$au3$1(a)fred.mathworks.com...
> Steven,
>
> Thanks for replying. In my code, I end up with a pruned tree, tmin. It
> looks like this when I query it at the command prompt:

*snip*

> My question is how do I stream this if...else text data into a .txt file.
> EVALC did not seem to help. At least it was not obvious to me.
> T=evalc(tmin) did not work as didn't T=evalc(tmin.disp) or
> T=evalc(tmin.display)

Look at the help for EVALC. What does it expect as input? What you
provided it in your 3 attempts is not what it was expecting.

Alternately, another approach you could use would be to use the DIARY
function to capture the display directly. The formatting on the diary file
might not be exactly the way you want it, though, and so you might want to
EVALC and "tweak" the string it returns.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: Ashwin on
Thanks. I tweaked the disp member function to accept a file handle and used that to write to file.
 |  Next  |  Last
Pages: 1 2
Prev: check_active_images
Next: Press keyboard code