From: HAJEINTHAN on
the command 'square' in matlab can be used to create a square wave. This command give the wave a default magnitude of -1 to +1. Is it possible for us to change the magnitude to our needs.

I need to create a square wave in matlab oscillating with a magnitude from 0 to +5. Could it be done? Any help provided will be appreciated.. Thank you..
From: ImageAnalyst on
Uh, I know this sounds really obvious, but did you try offsetting and
scaling it???
Worked for me. What happened when you tried it? What was your error
message?

workspace; % Display workspace panel.
sw = square(1:100);
sw2 = 5*(sw+1)/2;
figure;
plot(sw2, 'Linewidth', 3)
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
From: HAJEINTHAN on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <efbb695a-6c03-484a-9285-c904d6fb3c02(a)n16g2000yqm.googlegroups.com>...
> Uh, I know this sounds really obvious, but did you try offsetting and
> scaling it???
> Worked for me. What happened when you tried it? What was your error
> message?
>
> workspace; % Display workspace panel.
> sw = square(1:100);
> sw2 = 5*(sw+1)/2;
> figure;
> plot(sw2, 'Linewidth', 3)
> set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.

Hey thanks a lot,
i am pretty new to matlab... and thats probably a reason it didnt sound obvious to me... works perfect... Thank you very much
 | 
Pages: 1
Prev: count objects
Next: How to get Fourier descriptor