Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab - How to make a figure current? How to make an axes current?

If f is the figure handle, I wanted to use plot3(..) on it just like I would use plot(..), but this didn't work:

>> plot3(f, t, real(Y), imag(Y))
Error using plot3
Vectors must be the same lengths.

Then I figured out that the way to do this is to:

  1. First make the relevant figure current.

  2. Then use the plot3(..) function.

I can find what the current figure is using gcf, but how do I make a figure current (via its handle)?

like image 751
Evgeni Sergeev Avatar asked Oct 08 '12 04:10

Evgeni Sergeev


People also ask

How do I get current axis in MATLAB?

ax = gca returns the current axes (or standalone visualization) in the current figure. Use ax to get and set properties of the current axes. If there are no axes or charts in the current figure, then gca creates a Cartesian axes object.

How can calculate current figure in MATLAB?

command: figure(f) %Makes the figure current. Also, if I did something like this: f = figure('IntegerHandle','off'); % With unique, non-reusable handle.

How do you change the axis of a figure in MATLAB?

Change Axis LimitsCreate a line plot. Specify the axis limits using the xlim and ylim functions. For 3-D plots, use the zlim function. Pass the functions a two-element vector of the form [min max] .

How do you make an AXE in MATLAB?

First create two Axes objects and specify the positions. Display the box outline around each axes. Return the Axes objects as ax1 and ax2 . figure ax1 = axes('Position',[0.1 0.1 .


1 Answers

This method has my personal preference:

set(0, 'currentfigure', f);  %# for figures
set(f, 'currentaxes', axs);  %# for axes with handle axs on figure f

because these commands are their own documentation. I find

figure(f)

and the like confusing on first read -- do you create a new figure? or merely make an existing one active? -> more reading of the context is required.

like image 118
Rody Oldenhuis Avatar answered Nov 16 '22 00:11

Rody Oldenhuis