How to center Image

30 visualizzazioni (ultimi 30 giorni)
Jack Arnoldi
Jack Arnoldi il 28 Giu 2019
Risposto: Rahul Singhal il 28 Giu 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.

Risposta accettata

Rahul Singhal
Rahul Singhal il 28 Giu 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

Più risposte (0)

Categorie

Scopri di più su MATLAB Report Generator Task Examples in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by