Question
I have created a GUI with guide with an axes (called axes2) where I want to show a video preview of what a camera sees. I want the user to be able to select different resolutions but I want the size of the preview window to be fixed by my GUI. Unfortunately, when I run the following code it just displays a corner of the image (restricted by the size of the window). If I run the preview in a separate window, it works but I want it in the screen. I think it's possible because IMAQtool allows different resolutions and the preview always fits (unless of course the preview is always at some lower resolution). axes(handles.axes2); imshow(0); handles.iris = image; preview(handles.vid, handles.iris);
Expert Answer
Neeta Dsouza
PhD Expert
Answered Aug 23, 2026
image is a function - so you don't want to use that.
In short you want to do something like
handleToImageInAxes = image( zeros([videoRes(2), videoRes(1), numberOfBands], 'uint8') ); fprintf(1, 'About to call preview...\n'); % Turn on the live video. preview(vidobj, handleToImageInAxes);
but there's more to it than that, so see the attached function.
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related guide Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →