Domanda

I want to show my graphical output of a Matlab program in a different pre-fixed window. So, that whenever I run the program, the output should be inside this figure. I followed a tutorial on the Matlab website and the created the figure as follows:

Created figure

Until here everything is fine.

Now, when I what to show some output inside this figure with figure(1), Imshow(A), the figure size and position is automatically changed, which I do not want. I get something like this:

Unwanted result

Now my question is: How do I show the outputs in the pre-calculated position and size?

È stato utile?

Soluzione

Try displaying your images with 'InitialMagnification' set to 'fit':

>> figure(1); imshow( A, 'InitialMagnification', 'fit' );

If this does not work, you might try set 'Position' of figure after showing the image.
Alternatively, you might want to consider using imagesc with axis image to display the images.

Altri suggerimenti

Suggestion:

( 0. all of the figures are already created, but without the images loaded)

  1. Save the position before loading the images, eg. like: PosFig1=get(,'Position')...
  2. Load the images etc.
  3. Set the figures to there old poistions, like: set((,'Position',PosFig1)

Of course, you could put the positions into some kind of structure, to make the code to look nicer and more flexibel and so on :)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top