Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You seem to be having a lot of trouble figuring this out. Here's the image I assume you want to generate:</p> <p><img src="https://i37.photobucket.com/albums/e77/kpeaton/I_Heart_MATLAB.jpg" alt="alt text"></p> <p>First, I started with the functions <code>heart</code> and <code>I_Heart_Math</code> that I posted in <a href="https://stackoverflow.com/questions/1526898/matlab-and-plot/1589735#1589735">my answer to your other question</a> (which use <a href="http://www.mathworks.com/matlabcentral/fileexchange/278-arrow-m" rel="nofollow noreferrer">arrow.m</a> and <a href="http://www.mathworks.com/matlabcentral/fileexchange/20979-myaa-my-anti-alias-for-matlab" rel="nofollow noreferrer">myaa.m</a> from <a href="http://www.mathworks.com/matlabcentral/fileexchange/" rel="nofollow noreferrer">The MathWorks File Exchange</a>). I removed all the code in <code>I_Heart_Math</code> that was related to plotting the word "Math" and reduced the size of the figure window.</p> <p>Next I had to generate and plot the MATLAB L-shaped membrane logo. In MATLAB you can type <code>logo</code> and it will open a new figure with the logo displayed on a black background. You can look at the code that generates the figure by typing <code>type logo</code> in MATLAB, or you can look at <a href="http://www.mathworks.com/products/matlab/demos.html?file=/products/demos/shipping/matlab/logo.html" rel="nofollow noreferrer">this MathWorks demo page</a>.</p> <p>The <code>logo</code> code required a few modifications. Since I wanted to add the logo to an already existing figure window, I removed the code that created a new figure window. I changed a few properties for the logo axes as well: the <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/axes_props.html#Parent" rel="nofollow noreferrer">'Parent' property</a> was set to the current figure window (<a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/gcf.html" rel="nofollow noreferrer">GCF</a>), the <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/axes_props.html#Units" rel="nofollow noreferrer">'Units' property</a> was set to 'pixels', and the <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/axes_props.html#Position" rel="nofollow noreferrer">'Position' property</a> was changed to position the logo axes next to the heart axes within the figure window.</p> <p>Putting it all together, here's the new <code>I_Heart_MATLAB</code> code to generate the above image:</p> <pre><code>function I_Heart_MATLAB % Initialize heart plot and adjust figure and axes settings: heart; set(gcf,'Position',[200 200 640 300],'Name','Original image'); offset = get(gca,'CameraPosition')-get(gca,'CameraTarget'); offset = 35.*offset./norm(offset); set(gca,'Position',[65 -9 300 300],'CameraViewAngle',6,... 'XLim',[21+offset(1) 70],'YLim',[16+offset(2) 63],... 'ZLim',[32 81+offset(3)]); % Create the axes and labels, offsetting them in front of the % heart to give the appearance they are passing through it: arrowStarts = [81 51 51; 51 86 51; 51 51 32]+repmat(offset,3,1); arrowEnds = [21 51 51; 51 16 51; 51 51 81]+repmat(offset,3,1); arrow(arrowStarts,arrowEnds,5,40,40); text('Position',[22 52 48]+offset,'String','x','FontSize',12); text('Position',[50 17 49]+offset,'String','y','FontSize',12); text('Position',[46.5 51 81.5]+offset,'String','z','FontSize',12); % Create the equation text: text('Position',[51 47 28],'FontName','Bookman','FontSize',8,... 'HorizontalAlignment','center',... 'String',{'(x^2+^9/_4y^2+z^2-1)^3-x^2z^3-^9/_{80}y^2z^3=0'; ... '-3 \leq x,y,z \leq 3'}); % Create the large-type text: hI = text('Position',[4 52 69.5],'String','I',... 'FontAngle','italic','FontName','Trebuchet MS',... 'FontSize',116,'FontWeight','bold'); % Create and plot the L-shaped membrane logo: logoData = 40*membrane(1,25); logoAxes = axes('Parent',gcf,'Units','pixels',... 'Position',[335 21 280 280],... 'CameraPosition', [-193.4013 -265.1546 220.4819],... 'CameraTarget',[26 26 10],'CameraUpVector',[0 0 1],... 'CameraViewAngle',9.5,'DataAspectRatio',[1 1 .9],... 'XLim',[1 51],'YLim',[1 51],'ZLim',[-13 40],... 'Visible','off'); surface(logoData,'Parent',logoAxes,'EdgeColor','none',... 'FaceColor',[0.9 0.2 0.2],'FaceLighting','phong',... 'AmbientStrength',0.3,'DiffuseStrength',0.6,... 'Clipping','off','BackFaceLighting','lit',... 'SpecularStrength',1.1,'SpecularColorReflectance',1,... 'SpecularExponent',7); light('Parent',logoAxes,'Position',[40 100 20],'Color',[0 0.8 0.8],... 'Style','local'); light('Parent',logoAxes,'Position',[.5 -1 .4],'Color',[0.8 0.8 0]); % Create an anti-aliased version of the figure too (the larger % fonts need some adjustment to do this... not sure why): set(hI,'FontSize',86); myaa; set(hI,'FontSize',116); set(gcf,'Name','Anti-aliased image'); end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload