I managed to solve that problem:
%scale
Y=(Xmin(X))/(max(X)min(X));
plot (Y)
%truncate
index = find( X < 0 );
if (length(index) > 0);
Y(index) = zeros(length(index),1);
end
index = find( X >= 1 );
if (length(index) > 0)
Y(index) = ones(length(index),1);
end
index=find(X==0&X==1);
if length(index)>0
Y(index)=ones(length(index),1);
end
and it works perfectly
Now I use ginput in a loop to select two points from the graph.
How can I use truncate only between these selected points? I tried sth like this:
i=1;
while i>=1;
[x,y] = ginput(2);
line(x,y,'Color','g')
%scale
Y=(Xmin(X))/(max(X)min(X));
plot (Y)
%truncate
for X=x:y
index = find( X < 0 );
if (length(index) > 0);
Y(index) = zeros(length(index),1);
end
index = find( X >= 1 );
if (length(index) > 0)
Y(index) = ones(length(index),1);
end
index=find(X==0&X==1);
if length(index)>0
Y(index)=ones(length(index),1);
end
end
plot(Y,'m')
That is, I used a for loop but it doesn't seem to do the work? Any ideas?
