Matlab's native figure command does not give you an option to make your figure full screen in 1 step. Instead first you have to find the screen resolution and then give your figure command the size of the screen.
First thing you want to do is:
screen_size = get(0, 'ScreenSize');
This will return a 4 element array: (left, bottom, width, height);
The ones we are interested are the "width" and "height".
Now we have the size of the screen, we can make our figure full screen:
f1 = figure(1);
set(f1, 'Position', [0 0 screen_size(3) screen_size(4) ] );
Now you should have a figure that is full screen.
Showing posts with label Matlab. Show all posts
Showing posts with label Matlab. Show all posts
Monday, June 30, 2008
Wednesday, June 04, 2008
Export figures in Matlab without displaying them
Assuming you have a lot of figures to plot, but you do not want to wait and see them in Matlab's figure window. There is a way you can export all of your figures without displaying them. This might also save you some time, since you are drawing them on the screen.
Here is how :
% Create a figure with visibility off
f = figure('Visible','off');
% Then do your plot
plot
% Finally export the plot as an image
print('-dpng', 'test.png');
You can also make this in a loop (Which is very probable if you have too many figures).
Do this
for i:1, n
f = figure('Visible','off');
plot
filename = sprintf('plot-%d',i);
print('-dpng', filename);
end
This will give you 'n' png images with your plots in it.
Here is how :
% Create a figure with visibility off
f = figure('Visible','off');
% Then do your plot
plot
% Finally export the plot as an image
print('-dpng', 'test.png');
You can also make this in a loop (Which is very probable if you have too many figures).
Do this
for i:1, n
f = figure('Visible','off');
plot
filename = sprintf('plot-%d',i);
print('-dpng', filename);
end
This will give you 'n' png images with your plots in it.
Monday, January 14, 2008
Replacing certain values in matlab vectors
In Matlab if you need to replace certain values with a single value you can simple do this,
>u(find(isnan(u))) = [];
Using this will find and remove all the NaN (Not a Number) values.
If you want to remove any value you can simple use find again,
>u(find(u=9999)) = [];
This will remove all the values of u = 9999.
Be aware that applying this will make your vector shorter if there is any value removed.
>u(find(isnan(u))) = [];
Using this will find and remove all the NaN (Not a Number) values.
If you want to remove any value you can simple use find again,
>u(find(u=9999)) = [];
This will remove all the values of u = 9999.
Be aware that applying this will make your vector shorter if there is any value removed.
Subscribe to:
Posts (Atom)