How to center Image

조회 수: 59 (최근 30일)
Jack Arnoldi
Jack Arnoldi 2019년 6월 28일
답변: Rahul Singhal 2019년 6월 28일
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.

채택된 답변

Rahul Singhal
Rahul Singhal 2019년 6월 28일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Report Generator Task Examples에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by