# assigning particular value based on x asis

Printable View

• Jun 10th 2010, 10:55 PM
ganesh
assigning particular value based on x asis
sir,
i have a signal.it ends at say x=2 in xaxis.
i want to assign zero valuefrom x=2 upto x=3 in xaxis.can u tell me which command should i use for it
• Jun 10th 2010, 10:58 PM
pickslides
$\displaystyle y=0, x\in [2,3]$
• Jun 10th 2010, 11:00 PM
ganesh
what is the command for it in matlab
• Jun 10th 2010, 11:03 PM
pickslides
You never mentioned Matlab or what the signal was for $\displaystyle x<2$ and $\displaystyle x>3$
• Jun 10th 2010, 11:09 PM
ganesh
clc;
clear all;
Ytot=0.0;
f=100000;
for j=1:1
R=4E+6; % Synchronized Rate (Max)
dt=1/R; % Sampling Time for output
t=0;
Y=0;
Y1=0;
N=5; % Number of cycles
L=N/(dt*f); % Length of signal

for i=1:L
Y1(i)=4*(1-cos(t*2*pi*f/N))* sin(t*2*pi*f);
t=t+dt;
end
for i=1:L
Y(i)=0.0;
end
Y=[Y Y1 ];
if j==1
Ytot=[Y];
else
Ytot=[Ytot Y];
end

end
t=([1:1:length(Ytot)])*dt;
subplot(2,1,1)
plot(t,Ytot);

-------------------------------------------------------------------

this is the signal
i want to add more zeros to the end of the signal upto my desired value corresponding to x axis
can u tell me which is the matlab command that i should use
• Jun 11th 2010, 02:55 AM
elbarto
Try this:

Code:

clc; clear all; Ytot=0.0; f=100000; for j=1:1     R=4E+6; % Synchronized Rate (Max)     dt=1/R; % Sampling Time for output     t=0;     Y=0;     Y1=0;     N=5; % Number of cycles     L=N/(dt*f); % Length of signal         for i=1:L         Y1(i)=4*(1-cos(t*2*pi*f/N))* sin(t*2*pi*f);         t=t+dt;     end     for i=1:L         Y(i)=0.0;     end     Y=[Y Y1 ];     if j==1         Ytot=[Y];     else         Ytot=[Ytot Y];     end             end t=([1:1:length(Ytot)])*dt; h = subplot(2,1,1) plot(t,Ytot); set(h,'xlim',[0.6 0.9].*10^(-4))%<---------------------------------------------------
Regards Elbarto