Ask an expert. Trust the answer.

Your academic and career questions answered by verified experts

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

Date: 2022-07-11 11:03:16

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)?  

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.


Why Matlabhelpers ?

Our Matlab assignment helpers for online MATLAB assignment help service take utmost care of your assignments by keeping the codes simple yet of high-quality. We offer the most reliable MATLAB solutions to students pursuing their Computer Science course from the Monash University, the University of Sydney, the University of New South Wales, the University of Melbourne; to name a few. Approach us today for best Matlab solutions online!

whatsApp order on matlabhelpers.com

telegram order on matlabsolutions.com