How to center Image

30 visualizaciones (últimos 30 días)
Jack Arnoldi
Jack Arnoldi el 28 de Jun. de 2019
Respondida: Rahul Singhal el 28 de Jun. de 2019
I have an image object of the type mlreportgen.dom.Image and I want to center it but I don't know how to do it. I tried with HAlign but it doesn't work and gives me the error and indeed the align property doesn't seem to be there in the Image documentation...
Unable to perform assignment because dot indexing is not supported for variables of this type.
My code is:
PlotImg = Image(path);
PlotImg.Style = {Height('6in')};
PlotImg.Style = {HAlign('center')}; % that gives an error
add(SectionPASS, PlotImg);
So what should I do to center this Image in my report ?
Thank you in advance.

Respuesta aceptada

Rahul Singhal
Rahul Singhal el 28 de Jun. de 2019
Hi Jack,
I am not sure about the error, but in your code you are overriding the Style property value of the Image. So the Height format will not be honored. To concatenate the formats in the Style property, I would suggest:
PlotImg.Style = {Height('6in'), HAlign('center')};
Or
PlotImg.Style = {Height('6in')};
PlotImg.Style = [PlotImg.Style {HAlign('center')}];
Also, I tried with a sample script and was able to align the image to the center using the HAlign format.
import mlreportgen.dom.*
d = Document('output','pdf');
image = Image(which('ngc6543a.jpg'));
image.Style = {Height('2in'), HAlign('center')};
append(d, image);
close(d);
rptview(d);
Thanks,
Rahul

Más respuestas (0)

Categorías

Más información sobre MATLAB Report Generator Task Examples en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by