Based on the matlab documentation example (https://www.mathworks.com/help/rptgen/ug/side-by-side-images.html) I was trying to repeat it with other two images.
Code:
close all;
clear all;
clc;
import mlreportgen.report.*
import mlreportgen.dom.*
linkImage = image(imread('https://www.aviationmegastore.com/img/prod/full/f/9/167408_0.jpg'));
RGBImage = image(imread('sevilla.jpg'));
rpt = Report('PDFreport', 'pdf');
imgStyle = {ScaleToFit(true)};
RGBImage.Style = imgStyle;
linkImage.Style = imgStyle;
lot = Table({RGBImage, ' ', linkImage});
lot.entry(1,1).Style = {Width('3.2in'), Height('3in')};
lot.entry(1,2).Style = {Width('.2in'), Height('3in')};
lot.entry(1,3).Style = {Width('3.2in'), Height('3in')};
lot.Style = {ResizeToFitContents(false), Width('100%')};
add(rpt, lot);
close(rpt);
rptview(rpt);
but I get this error:
Unrecognized property 'Style' for class 'matlab.graphics.primitive.Image'.
Error in Untitled (line 13)
RGBImage.Style = imgStyle;
How do I fix it and what causing it?
CodePudding user response:
image
and Image
are not the same thing. When you do:
import mlreportgen.report.*
import mlreportgen.dom.*
You are bringing in different components that include the properties you are after. Using image
returns a matlab.graphics.primitive.Image
. If you use Image
you will get a mlreportgen.dom.Image
which has Style
.
A quick test shows that the included sevilla.jpg
loaded fine but I did need to save a local copy of 167408_0.jpg
in order for Image
to process it. So the correct commands after copying the file to the working directory are:
RGBImage = Image(which('sevilla.jpg'));
linkImage = Image('167408_0.jpg');