Asked by Daniel Gray
on 4 Jul 2017

I am running an experiment and currently have a 300x300 zeros matrix and the lower half filled with ones to get a half-plane image. Now I want to 'tilt' this plane with different angles to see how this changes what I am testing. Is there a code I could use to do this?

Any more questions on this (cause I know this could be a bit confusing) please just drop a comment or send me a message.

Answer by Jan
on 4 Jul 2017

Edited by Jan
on 4 Jul 2017

x = 1:300;

y = 1:300;

m = atan(30 * pi / 180); % 30 deg

k = bsxfun(@plus, m * (x - 150), y.' - 150) > 0; % Rotate around [150,150]

imagesc(k);

Since R2016b this is simpler:

k = (m * (x - 150)) + (y.' - 150) > 0;

Jan
on 5 Jul 2017

Daniel Gray
on 5 Jul 2017

Jan
on 6 Jul 2017

Well, in the code I've posted I used 30 deg as angle. You can replace the angle by a variable:

YourAngle = 17.3; % deg

m = atan(YourAngle * pi / 180); % 30 deg

But if you ran the code with 45 deg, you have done this already. Therefore I do not understand, what the problem is now. What is the difference between the result my code creates and the wanted matrix?

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 3 Comments

## José-Luis (view profile)

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/347327-i-want-to-vary-how-much-of-a-plane-is-filled-with-the-angle-of-the-plane-with-the-horizontal-any-he#comment_466365

## Jan (view profile)

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/347327-i-want-to-vary-how-much-of-a-plane-is-filled-with-the-angle-of-the-plane-with-the-horizontal-any-he#comment_466368

## Daniel Gray (view profile)

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/347327-i-want-to-vary-how-much-of-a-plane-is-filled-with-the-angle-of-the-plane-with-the-horizontal-any-he#comment_466369

Sign in to comment.