How to stretch the cells of a matrix ?

2 ビュー (過去 30 日間)
Alexandre Briclot
Alexandre Briclot 2017 年 10 月 21 日
回答済み: Pippa Williams 2020 年 2 月 11 日
Hello all, Let's say I have a 30*30 matrix and I want to display an image of the data in it, but I want the image to be for example 2 times longer than wide. I just want to "stretch" the cells in the x-direction. The ratio between the length and the width would be given by the ratio between Lx and Ly. I found nothing related to this using the image function in Matlab.
Thanks.

採用された回答

Jan
Jan 2017 年 10 月 21 日
編集済み: Jan 2017 年 10 月 21 日
img = rand(30, 30, 3);
figure('Menubar', 'none', 'Toolbar', 'none');
axh = axes;
image(axh, img);
axh.DataAspectRatio = [1,2,1];
  1 件のコメント
Alexandre Briclot
Alexandre Briclot 2017 年 10 月 21 日
Thank you very much !

サインインしてコメントする。

その他の回答 (1 件)

Pippa Williams
Pippa Williams 2020 年 2 月 11 日
Another (perhaps simpler) option if you have R2015a or later: repelem ("repeat elements") will also do.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by