Specify Path for Image in Report Generator

3 views (last 30 days)
Matt O'Brien
Matt O'Brien on 25 Nov 2022
Edited: Stephen23 on 25 Nov 2022
I have a pdf generated via MatLab Report Generator. I have a few remaining issues. I have spent days trying to resolve via search of this and other forums.
I am posting each issue individually.
This issue. Specify Path for Image in Report Generator
The following line is used in an Example Report. This works and finds the image in the local directory or in a directory via the addpath function.
img1 = Image(which('ngc6543a.jpg'));
Unfortunately, I will be supplied an Excel sheet which will supply a list of images with the full image path. There may be hundreds of images and directories in the list (and the database has more than 500,000 images). I am comfortable splitting the path and filename into different variables.
Simplified file list:
'C:\Dir1\ngc6543a.jpg'
'G:\Dir2\ngc6543a.jpg'
'S:\Dir1\SubDir\ngc6543a.jpg'
When I tried the following I always get an error.
img1 = Image(which('C:\Dir1\ngc6543a.jpg'));
Please help me use the correct syntax to include the full path, eg. 'C:\Dir1\ngc6543a.jpg'.
I do not believe it is feasible to keep adding the image 'path' to the system addpath function for such high volumes.
Also... if anyone could please post a link to the Image(which)) syntax. I cannot find it.
  1 Comment
Stephen23
Stephen23 on 25 Nov 2022
Edited: Stephen23 on 25 Nov 2022
"Please help me use the correct syntax to include the full path, eg. 'C:\Dir1\ngc6543a.jpg'."
img1 = Image('C:\Dir1\ngc6543a.jpg'); % get rid of WHICH()

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 25 Nov 2022
I don't know what "Image" is. Is that your own function or a special function for the Report Generator? It's not the built-in image function because MATLAB is case sensitive.
And what's the point of using which()?
Since you already seem to have the filenames in a cell array or table because you read them in from Excel, why not simply use the index of the one you want?
[numbers, fileNames, raw] = xlsread(workbookName);
img1 = Image(fileNames{3}); % Use filename #3.
  12 Comments
Matt O'Brien
Matt O'Brien on 25 Nov 2022
I found the Which documentation. https://uk.mathworks.com/help/matlab/ref/which.html
The key was to add the word function to the search parameter.
Stephen23
Stephen23 on 25 Nov 2022
Edited: Stephen23 on 25 Nov 2022
"I cannot find any documentation for Which. I cannot find any documentation for Image."
I gave links to both of those in my previous comment, and I also explained the exact three clicks you need to find the Image documentation from the page you already were looking at. But here they are again:
I am sure that after three days reading about this topic you have already read the entire Report Generator documentation twice over, but perhaps someone else might find these screenshots useful:
"If anyone can point me to the Documentation for 'Which' and 'Image' I would really appreciate it."
Tip: practice using the documentation. Always look at what is displayed in the browser (LHS) and at the very top and bottom of every page. There is a lot of hyperlinking and a lot of information, so you have to keep your eyes open.

Sign in to comment.

Categories

Find more on File Operations in Help Center and File Exchange

Tags

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!