Filter löschen
Filter löschen

Can an interactive figure be exported to html?

55 Ansichten (letzte 30 Tage)
Claire Wilson
Claire Wilson am 24 Aug. 2018
Kommentiert: Rishi Binda am 28 Aug. 2018
Hi, Not sure if this is feasible or not.
I would like to export an interactive figure which contains a scroll bar to html or something similar, so that the end user who does not have MATLAB can use the figure interactively.
I've found a few functions which relate to 3D plots however none are suitable for the type of figure i'm trying to export.
example code;
% Generate and plot data
x=0:1e-2:2*pi;
y=sin(x);
dx=2;
%%dx is the width of the axis 'window'
a=gca;
p=plot(x,y);
% Set appropriate axis limits and settings
set(gcf,'doublebuffer','on');
%%This avoids flickering when updating the axis
set(a,'xlim',[0 dx]);
set(a,'ylim',[min(y) max(y)]);
% Generate constants for use in uicontrol initialization
pos=get(a,'position');
Newpos=[pos(1) pos(2)-0.1 pos(3) 0.05];
%%This will create a slider which is just underneath the axis
%%but still leaves room for the axis labels above the slider
xmax=max(x);
S=['set(gca,''xlim'',get(gcbo,''value'')+[0 ' num2str(dx) '])'];
%%Setting up callback string to modify XLim of axis (gca)
%%based on the position of the slider (gcbo)
% Creating Uicontrol
h=uicontrol('style','slider',...
'units','normalized','position',Newpos,...
'callback',S,'min',0,'max',xmax-dx);

Antworten (1)

Rishi Binda
Rishi Binda am 28 Aug. 2018
Hello Claire,
I understand that you are looking to export a 3-D plot with interaction capability to a HTML or some other file. There are a couple of third party toolboxes that have been developed to make use of the U3D PDF-style.
This will save the figure as U3D file for inclusion as an interactive 3-dimensional figure within a PDF. This will not work for HTML.
Note that MathWorks does not guarantee or warrant the use or content of these third-party submissions. Any questions, issues, or complaints should be directed to the contributing author.
I hope this helps your issue.
  2 Kommentare
Claire Wilson
Claire Wilson am 28 Aug. 2018
Hi Rishi,
Thanks for your answer.
It's not a 3D plot i'm trying to export to HTML, is just a 2D plot with interactive features such as a scroll bar (example in original question).
The 3rd party tool boxes for U3D don't work for 2D plots, or at least i can't get them to...
I think i'm just going to build a GUI instead.
thanks for your help.
Claire
Rishi Binda
Rishi Binda am 28 Aug. 2018
If you want the interactive figure to work on a machine without MATLAB, I suggest you to install MATLAB Compiler Runtime(MCR) on the machine. It is free and you can package your script that generates your plot as an app and distribute it.
Hope that's useful.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by