Write a MATLAB function called ‘loadim’ that will automatically load a binary da
ID: 3746223 • Letter: W
Question
Write a MATLAB function called ‘loadim’ that will automatically load a binary data file with user-specified size/name and display it. This involves the creation of an ‘*.m’ file. This function should allow the user to specify the image size in rows and columns, as well as the image name. It should work for any binary data file. It should store the image under a user-specified variable name in the matlab workspace. The syntax to execute the function should be: y = loadim(‘filename’, xsize, ysize).
Explanation / Answer
A binary data file is assumed to a be containing a row-column arrangement of 0's and 1's. It will effectively be a sparse matrix. Though the usage of xsize and ysize is unclear. For the given task, the following function should suffice.
%================================
function [ im_var ] = loadim( filename, xsize, ysize )
im_var = imread(filename);
imtool(im_var);
end
%================================
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.