How to center Image
조회 수: 35 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!