Clear Filters
Clear Filters

image array save it

2 views (last 30 days)
Patrick Brown
Patrick Brown on 13 Mar 2017
Answered: Walter Roberson on 13 Mar 2017
I have an image array fig and I want to save it but I get this error
fig =
1x2 Image array:
Image Image
>> saveas(fig,'a','pdf')
Error using saveas (line 58)
Invalid handle.
thanks!

Answers (1)

Walter Roberson
Walter Roberson on 13 Mar 2017
You have two difficulties:
1) One of your images is already deleted. That can happen if you create images in a loop (or implicit loop) without "hold on" being on. For example,
for K = 1 : 3; fig(K) = imagesc(rand(40,80,3)); end
The imagesc() for K == 1 draws an image, but then when it is time to imagesc() for K == 2, because hold is not on, it does a cla, which deletes the image object created for K == 1.
This is your most immediate problem: you are working with the handle to something already deleted.
2) When you get that solved, you have the problem that saveas() only accepts scalars for its first argument. You cannot saveas() a pair of images. If the two have a common parent axes you can saveas() that common parent axes.

Categories

Find more on Display Image in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!