Step function with a slanted edge

Hi,
I want to write a code for a step function with its edge slanted at a small angle. I could write a code for simple step function but I want to give an angle to its edge. In addition to that, I want to give pixel value to my step function to be 100x100. How can I do that?
function out = step_1(x)
out = 0 * x;
out(find(x==0))=0.5;
out(find(x>0)) = 1;
end

Respuestas (1)

Image Analyst
Image Analyst el 23 de Jul. de 2017

0 votos

3 comentarios

Thanks for your response. I tried it and code is attached;
fs=500; %Sampling Frequency
x=-5:1/fs:5;
y=x;
[X,Y]=meshgrid(x,y);
f = step_1(x);
figure(1)
stem(x, f);
axis([-5 5 -1 2]);
figure(2)
plot(x,f, 'r');
axis([-5 5 0 1]);
title('Step Funtion');
xlabel('Distance');
ylabel('Amplitude');
figure(3)
imagesc(f);
xlabel('x (m)');
ylabel('Amplitude');
colormap('gray');
axis square;
axis xy;
tform = affine2d([1 0 0; .5 1 0; 0 0 1]);
J = imwarp(f,tform);
figure;
imshow(J)
but, I got the following error:
Warning: Image is too big to fit on screen; displaying at 33% > In images.internal.initSize (line 71) In imshow (line 328) In step_1_2 (line 29) Also, How can I set the pixel value of my image?
Image Analyst
Image Analyst el 23 de Jul. de 2017
That's just a notice. You can ignore it. See attached demo for more info on how to zoom.
Image Analyst
Image Analyst el 24 de Jul. de 2017
Yes, warnings are in orange text, and real errors are in red text.

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 23 de Jul. de 2017

Comentada:

el 24 de Jul. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by