Thread Subject:
Interactive Books with MATLAB

Subject: Interactive Books with MATLAB

From: Martin Trauth

Date: 5 Jul, 2012 08:09:07

Message: 1 of 19

Dear all,

I know about the publishing feature of MATLAB but this creates static documents only. Is there a way to create interactive books with MATLAB, i.e. you read the book and run the scripts within the book, manipulate the graphs, even change the code (maybe without being able to save the modifcations) and see the changes of the graph?

With the competitor software Mathematica (which I don't like too much) you can publish interactive books and read/use them with the Wolfram CDF Player or webMathematica. I haven't ever seen it running but I know from some colleague that he works on interactive books with Mathematica.

Regards, Martin

Subject: Interactive Books with MATLAB

From: Nasser M. Abbasi

Date: 5 Jul, 2012 10:26:16

Message: 2 of 19

On 7/5/2012 3:09 AM, Martin Trauth wrote:
> Dear all,
>
> I know about the publishing feature of MATLAB but this creates static documents only.
> Is there a way to create interactive books with MATLAB, i.e. you read the
> book and run the scripts within the book, manipulate the graphs, even change
>the code (maybe without being able to save the modifcations) and see the changes of the graph?
>

Impossible with Matlab. I asked about this few times. Mathworks is not
interested in making a Matlab function run as 'applet' on the web
using a plugin that implements the run-time, like one can do now
with Mathematica.

> With the competitor software Mathematica (which I don't like too much) you can
>publish interactive books and read/use them with the Wolfram CDF Player or
>webMathematica. I haven't ever seen it running but I know from some
>colleague that he works on interactive books with Mathematica.
>

Yes. I program in both Matlab and Mathematica. This feature is
what I like most about Mathematia over Matlab. I can make a program
and put it on the web as an applet and any one can run it
without them having to have Mathematica. Only the browser with
the plugin installed in it (like Java applet). You can run them
now, just go to Wolfram demo page and there are over 8,000 applets
now listed there. Just google Mathematica demonstrations and you'll
see them.

I wish Mathworks will do something like this.

ps. Mathematica is nice also, I like it, and like Matlab also.
But Mathematica is different, it is a functional language and
pattern based, while Matlab is an imperative. So it takes more time
getting used to compared to Matlab.

--Nasser

Subject: Interactive Books with MATLAB

From: Martin Trauth

Date: 6 Jul, 2012 16:04:08

Message: 3 of 19

Dear Nasser,

thanks for your reply. Indeed very sad. The MathWorks Inc. always a little longer, there are many examples for this.

Martin

Subject: Interactive Books with MATLAB

From: Martin Trauth

Date: 26 Aug, 2012 14:54:11

Message: 4 of 19

I just got an iPad and continue playing around with interactive books about MATLAB. When using the software Apple iBooks Author you can easily create eBooks for iPads which include interactive 3D objectes. One easy way to do it is to use Google SketchUp to create 3D objects. The objects are exported as COLLADA .dae files that can be imported into an eBook. The problem is how to export 3D graphics to be imported into SketchUp? Or how to directly create .dae files from MATLAB?

Regards, Martin

Subject: Interactive Books with MATLAB

From: Martin Trauth

Date: 30 Aug, 2012 15:07:08

Message: 5 of 19

I made some progress now, here a recipe that works well except for the fact that the mesh looses all colors. I don't know when this happens, either when creating the Wavefront .obj file or the Collada .dae file. I create a surface plots with

[u,v]=meshgrid(-6:0.5:6,-6:0.5:6);
x=u; y=v; z=u.^2+v.^2;
surf(x,y,z)

Then I use SAVEOBJMESH that I found here

http://www.nada.kth.se/~asa/Ray/matlabobj.html

to create the .obj file. This can be imported in many software tools, some of them being free, such as MeshLab (http://meshlab.sourceforge.net), and from there you can export it as .dae file. The .dae goes into the iBooks Author file and then you can rotate the surface plot in the eBook you have created.

The problem: Where did all the colors go? You can make lots of modifications of the plot in MeshLab but the original MATLAB colors are not preserved. Any ideas?

Subject: Interactive Books with MATLAB

From: Martin Trauth

Date: 31 Aug, 2012 13:30:08

Message: 6 of 19

Here is the next chapter. I gave up the OBJ format and use the VRML format instead. And yes, it preserves the colors, at least on one side of the surface.

[u,v]=meshgrid(-6:0.5:6,-6:0.5:6);
x=u; y=v; z=u.^2+v.^2;
h = surf(x,y,z);
vrml(gcf,'example.wrl')

The VRML file example.wrl can be imported into MeshLab (free), exported as 3DS file, which can be imported into Google SketchUp to be converted into a Collada DAE file, which in turn can be included in an Apple iBooks Author file. It rotates smoothly on an iPad. Where did the colors of the other side of the surface go? They are intact in MeshLab but disappeared when importing it into Google SketchUp the upper side of the surface is gray.

Subject: Interactive Books with MATLAB

From: Martin Trauth

Date: 4 Sep, 2012 07:54:07

Message: 7 of 19

The alternative way to create interactive books is the interactive PDF. I found some tools in the file exchange like the ones by Alexandre Gramfort and Ioannis Filippidis but all of them seem to require some LaTeX tools to be used. I have used LaTeX a little bit in the 90s but never again; my textbooks are all done with Adobe InDesign instead.

Does anyone know about a way to create interactive PDFs without LaTeX? I tried the U3D format that I have created from a VRML from MATLAB using the function VRML.m. Unfortunately, the function VRML.m says in its help that it doesn't export the graphics as it is. In particular I can't see axis, the surface is colored only on one side, among other things. I have imported the VRML file into MeshLab that works fine. Exporting the U3D also works, you can import it into Adobe Acrobat CS5 without getting an error message but you don't see anything there.

Martin

Subject: Interactive Books with MATLAB

From: Richard Crozier

Date: 4 Sep, 2012 13:07:06

Message: 8 of 19

"Martin Trauth" <trauth@geo.uni-potsdam.de> wrote in message <k24c2v$3u4$1@newscl01ah.mathworks.com>...
> The alternative way to create interactive books is the interactive PDF. I found some tools in the file exchange like the ones by Alexandre Gramfort and Ioannis Filippidis but all of them seem to require some LaTeX tools to be used. I have used LaTeX a little bit in the 90s but never again; my textbooks are all done with Adobe InDesign instead.
>
> Does anyone know about a way to create interactive PDFs without LaTeX? I tried the U3D format that I have created from a VRML from MATLAB using the function VRML.m. Unfortunately, the function VRML.m says in its help that it doesn't export the graphics as it is. In particular I can't see axis, the surface is colored only on one side, among other things. I have imported the VRML file into MeshLab that works fine. Exporting the U3D also works, you can import it into Adobe Acrobat CS5 without getting an error message but you don't see anything there.
>
> Martin

You should consider having another look a LaTeX, you might find things have moved on considerably since the 90s. There are a number of excellent editors/IDE for working with it now which take the learning curve down somewhat.

Try TexnicCenter with MikTeX on windows, or TexWorks (several platforms, comes with MikTex). There is also Lyx (http://www.lyx.org) which is a sort of semi-what-you-see-is-what-you-get (they say what-you-see-is-what-you-mean). It's available for multiple platfomrs.

Another advantage of LaTeX is that it is possible to create html directly from the LaTeX source (although this isn't straightforward).

Subject: Interactive Books with MATLAB

From: Martin Trauth

Date: 4 Sep, 2012 13:28:18

Message: 9 of 19

> You should consider having another look a LaTeX, you might find things have moved on considerably since the 90s.

Thanks for your reply, much appreciated but I am not interested in LaTeX. I just need 3D figures rotating in an eBook. I have tried various approaches suggested here and in the file exchange. Unfortunately they all require installation of additional tools such as LaTeX or C++ compilers. Not so easy ...

Subject: Interactive Books with MATLAB

From: Martin Trauth

Date: 4 Sep, 2012 21:14:07

Message: 10 of 19

I got it working now. It seems that the COLLADA format and its converters have lots of incompatibilites, versions seem to be very important. Here is a recipe to import MATLAB interactive 3D objects into Apple iBooks Authors to be used on an iPad.

1) Create a 3D object with MATLAB e.g. with SUFR and export it as VRML file using vrml(gcf,'filename.wrl').
2) Import the VRML file into the free software MeshLab, switch off the light, export it as U3D file with colors and normals.
3) Import the U3D file into the free software Blender, remove the vertices of the cube, save as COLLADA DAE file. This file won't work with Apple iBooks Author.
4) Import the DAE file into the free software Google SketchUp and save it again as a DAE file. Maybe some of the problems of the DAE file of Blender are fixed by this.
5) Import the DAE file into Apple iBooks Authors.

Subject: Interactive Books with MATLAB

From: Richard Crozier

Date: 5 Sep, 2012 10:28:07

Message: 11 of 19

"Martin Trauth" <trauth@geo.uni-potsdam.de> wrote in message <k25quv$55i$1@newscl01ah.mathworks.com>...
> I got it working now. It seems that the COLLADA format and its converters have lots of incompatibilites, versions seem to be very important. Here is a recipe to import MATLAB interactive 3D objects into Apple iBooks Authors to be used on an iPad.
>
> 1) Create a 3D object with MATLAB e.g. with SUFR and export it as VRML file using vrml(gcf,'filename.wrl').
> 2) Import the VRML file into the free software MeshLab, switch off the light, export it as U3D file with colors and normals.
> 3) Import the U3D file into the free software Blender, remove the vertices of the cube, save as COLLADA DAE file. This file won't work with Apple iBooks Author.
> 4) Import the DAE file into the free software Google SketchUp and save it again as a DAE file. Maybe some of the problems of the DAE file of Blender are fixed by this.
> 5) Import the DAE file into Apple iBooks Authors.

There is a tool on the file exchange for creating u3d files from figures directly:

http://www.mathworks.com/matlabcentral/fileexchange/37640-export-figure-to-3d-interactive-pdf

Did you try this and find it didn't work, or was unsuitable for some reason? I've never tried it myself.

Subject: Interactive Books with MATLAB

From: Martin Trauth

Date: 5 Sep, 2012 12:30:08

Message: 12 of 19

> There is a tool on the file exchange for creating u3d files from figures directly:

Yes, I have downloaded it but it seems to be a long way until you get it running including the installation of LaTeX and C++.

Subject: Interactive Books with MATLAB

From: Martin Trauth

Date: 11 Dec, 2012 12:53:07

Message: 13 of 19

Dear all,

I found a solution to create PDFs with rotatable 3D graphs from MATLAB without LaTeX. I am using R2012b with Mac OS 10.8.2. You don't need any additional toolboxes.

Kind regards, Martin

1. Create 3D Graph and export it with the (hidden) function VRML to create a VRML/WRL file.

[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
surf(Z);
vrml(gcf,'myexample.wrl')

2. Use the free software MESHLAB to import the VRML/WLR file. Export the graph as 3DS File.

3. Use the free software BLENDER to import the 3DS file. Select the CUBE in the right panel, open the CUBE directory by selecting the PLUS sign, select CUBE, then REMOVE VERTICES in the left panel of the user interface. Export the result as COLLADA DAE file.

4. Use the free software GOOGLE SKETCHUP to import the DAE file. Unfortunately you now need the commercial plugin SimLab PDF Exporter ($99) to create the PDF file. Don't modify the settings of the plugin, it just works fine as it is. You can use a trial before you buy it.

5. Open the PDF file in Acrobat. Use the Model Rendering Mode to modify the appearance of the 3D graph, e.g. hide/unhide mesh, control transparency, light etc.

Subject: Interactive Books with MATLAB

From: Martin Trauth

Date: 22 Feb, 2013 14:09:07

Message: 14 of 19

Dear all,

back to the Apple iBooks Author / iPad option with 3D MATLAB graphs.

A) I am still wondering why the function VRML in MATLAB has been discontinued. It still exists whereas it does not appear in Help. Instead The MathWorks promotes the Simulink 3D Animation Toolbox, which I got, but I never found a simple solution to export a surface plot as VRML file. Any suggestions on that? VRML unfortunately is very limited. For instance it can't export RGB images projected on a 3D surface, which would be very useful in earth sciences.

B) I haven't found a shortcut in the recipe posted in my first mail. You can import the VRML/WLR files into Blender but then the colors get lots. You can't open the COLLADA/DAE files from Blender in iBooks Author, no idea why. Is there another way to export rotatable 3D graphs from MATLAB except for the LaTex recipes that are in the file exchange? I never got these functions running.

B) While the 3D graphs look fine in MATLAB, they get lots of holes in MeshLab. You can use the Fill Hole routine in MeshLab but this is a very time consuming task, you have to select each hole individually, and the software usually crashes after pressing Fill. The 3D graph isn't very large, 120 x 120 pixels, but even this very small surface plot has holes after exporting it from MATLAB. It's not a MeshLab problem because the holes are also there if you import the graph into Blender.
 
C) Actually 3DS works better than U3D in step 3 in my first post.
 
D) Most importantly, the 3D graph in iBooks Author is shifted slightly to the bottom of the 3D box. The lower part of the graph is cut off while rotating the graph.
 
I haven't been able to solve these problems so far.
 
Tino

Subject: Interactive Books with MATLAB

From: Martin Trauth

Date: 24 Feb, 2013 12:35:06

Message: 15 of 19

Dear all,

I got two problems solved, the holes (B) and the position in the ebook (D). The solution is to replace the discontinued VRML function by the VRML tools included in the Simulink 3D Animation Toolbox. I got a license from the The MathWorks Book Program (very nice and supportive people) but getting started with it seemed to take some time, no easy and quick solution. Well, it seems that Stacey Gage did it for us almost a decade ago when he posted a recipe in the File Exchange:

http://www.mathworks.de/matlabcentral/fileexchange/5164-virtual-reality-terrain-modeling

It took a few minutes only to make Fig. 7.4 in my textbook "MATLAB Recipes for Earth Sciences" an interactive 3D graph. It really looks great now! Second, the newest versions of MeshLab and Google SketchUp make Blender unnessary, or is it the quality of the VRML/WRL file created with the Simulink 3D Animation Toolbox? The DAE files from MeshLab can be imported into Google Sketchup. Here I got problem (D) solved. You can easily change the proportions of the graph (scaling), the position of the graph in the axes (move) and moving the axes themselves (axes).

Tino.

Subject: Interactive Books with MATLAB

From: Nasser M. Abbasi

Date: 24 Feb, 2013 13:04:50

Message: 16 of 19

On 2/24/2013 6:35 AM, Martin Trauth wrote:


since you are interested in interactive books, here is a nice video
on one such book:

http://www.wolfram.com/mathematica/customer-stories/developing-interactive-textbooks-with-cdf.html

the book is "Eric Schulz, Co-author of Calculus, by Briggs and Cochran"

--Nasser

Subject: Interactive Books with MATLAB

From: Martin Trauth

Date: 24 Feb, 2013 13:20:07

Message: 17 of 19

"Nasser M. Abbasi" wrote in message <kgd35g$jbg$1@speranza.aioe.org>...
> since you are interested in interactive books, here is a nice video
> on one such book:
>
> http://www.wolfram.com/mathematica/customer-stories/developing-interactive-textbooks-with-cdf.html
>
> the book is "Eric Schulz, Co-author of Calculus, by Briggs and Cochran"
>
> --Nasser

Thanks, Nasser, very helpful! I wish we could do this with MATLAB!

Martin

Subject: Interactive Books with MATLAB

From: Scott

Date: 24 Feb, 2013 20:19:08

Message: 18 of 19

"Martin Trauth" <trauth@geo.uni-potsdam.de> wrote in message <jt3i33$557$1@newscl01ah.mathworks.com>...
> Dear all,
>
> I know about the publishing feature of MATLAB but this creates static documents only. Is there a way to create interactive books with MATLAB, i.e. you read the book and run the scripts within the book, manipulate the graphs, even change the code (maybe without being able to save the modifcations) and see the changes of the graph?
>
> With the competitor software Mathematica (which I don't like too much) you can publish interactive books and read/use them with the Wolfram CDF Player or webMathematica. I haven't ever seen it running but I know from some colleague that he works on interactive books with Mathematica.
>
> Regards, Martin

R (the open-source statistical programming language) now has a package called Shiny (go to www.rstudio.com) which lets you wrap R functions into applets. Obviously MATLAB has functionality that R doesn't have (and vice versa), but that could be another alternative if R would work for your needs and if you can spend the time learning it.

Subject: Interactive Books with MATLAB

From: Martin Trauth

Date: 24 Feb, 2013 20:43:07

Message: 19 of 19

> R (the open-source statistical programming language) now has a package called Shiny (go to www.rstudio.com) which lets you wrap R functions into applets. Obviously MATLAB has functionality that R doesn't have (and vice versa), but that could be another alternative if R would work for your needs and if you can spend the time learning it.

Thanks for this. Too late for me I am afraid, after having built a large library of routines with MATLAB over the last twenty years and having written two textbooks about it. I will check out about Shiny, however, to see what others do. I am sure The MathWorks will come up with something some time.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
latex Martin Trauth 4 Sep, 2012 03:59:10
interactive Martin Trauth 4 Sep, 2012 03:59:10
pdf Martin Trauth 4 Sep, 2012 03:59:10
ebook Martin Trauth 31 Aug, 2012 10:44:03
vrml Martin Trauth 31 Aug, 2012 10:43:30
wavefront Martin Trauth 31 Aug, 2012 10:43:30
collada Martin Trauth 31 Aug, 2012 10:43:30
rssFeed for this Thread

Contact us