From: Satish on
Hi all,

I have a plot from X=1:10 and Y=[-1.6209 1.3306 0.7849 0.1681 -0.3521 -0.6280 -0.6779 -0.9908 -1.6466 -2.1471 ].
I would like to convert the resulting plot into a matrix where corresponding point in y-axis is replaced by 1 and rest with 0.

resulting matrix can be like
z=1 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0
0 0 0 0 1 0 0 0 0
........

Hope i will get the code to do like this.

Thank you
From: dpb on
Satish wrote:
> Hi all,
>
> I have a plot from X=1:10 and Y=[-1.6209 1.3306 0.7849 0.1681
> -0.3521 -0.6280 -0.6779 -0.9908 -1.6466 -2.1471 ].
> I would like to convert the resulting plot into a matrix where
> corresponding point in y-axis is replaced by 1 and rest with 0.
>
> resulting matrix can be like
> z=1 0 0 0 0 0 0 0 0
> 1 0 0 0 0 0 0 0 0
> 0 1 0 0 0 0 0 0 0
> 0 0 1 0 0 0 0 0 0
> 0 0 0 1 0 0 0 0 0
> 0 0 0 0 1 0 0 0 0
> ........
....

If you mean lineprinter-type plotting, there are many historical
routines; I'd presume there would be quite a few that have code posted
that could be found on the net that would show the way.

Short on time; the general way I'd approach it in quick 'n dirty fashion
would be to scale the values to the range of the width of the array and
use round() and/or floor() to convert to an integer that would be the
index for each entry.

--
From: Satish on
dpb <none(a)non.net> wrote in message <hnlf5j$2qk$1(a)news.eternal-september.org>...
> Satish wrote:
> > Hi all,
> >
> > I have a plot from X=1:10 and Y=[-1.6209 1.3306 0.7849 0.1681
> > -0.3521 -0.6280 -0.6779 -0.9908 -1.6466 -2.1471 ].
> > I would like to convert the resulting plot into a matrix where
> > corresponding point in y-axis is replaced by 1 and rest with 0.
> >
> > resulting matrix can be like
> > z=1 0 0 0 0 0 0 0 0
> > 1 0 0 0 0 0 0 0 0
> > 0 1 0 0 0 0 0 0 0
> > 0 0 1 0 0 0 0 0 0
> > 0 0 0 1 0 0 0 0 0
> > 0 0 0 0 1 0 0 0 0
> > ........
> ...
>
> If you mean lineprinter-type plotting, there are many historical
> routines; I'd presume there would be quite a few that have code posted
> that could be found on the net that would show the way.
>
> Short on time; the general way I'd approach it in quick 'n dirty fashion
> would be to scale the values to the range of the width of the array and
> use round() and/or floor() to convert to an integer that would be the
> index for each entry.
>
> --Hi dpb,
Yeah i used scale the value before and used the rounding function as of below but that give the result for positive values of Y. But here I have negative values so I can't scale it.

If you have any idea than plz tell me.
Also you have told me about many historical routines for this kind of plotting but i didn't find the link. So it would be helpful for me if you can give some links related to this.


My previous code was as below:(but in previous code there was not any negative value of Y so it was working but it stops working now as it face negative value)


X=1:10;
Y=[-1.6209 1.3306 0.7849 0.1681
-0.3521 -0.6280 -0.6779 -0.9908 -1.6466 -2.1471 ]
temp=zeros();
for i=1:length(y)
value=round((y(i)/max(y))*10);
temp(value,i)=1;
end
From: dpb on
Satish wrote:
....

> ... But here I have negative values so I can't scale it.

....

Of course you can; it's simply a linear transformation -- you have two
points (min/max values) you want to scale to another range. That boils
down to solving two equations in two unknowns...

--
From: Satish on
dpb <none(a)non.net> wrote in message <hnm43d$7u9$1(a)news.eternal-september.org>...

> Of course you can; it's simply a linear transformation -- you have two
> points (min/max values) you want to scale to another range. That boils
> down to solving two equations in two unknowns...
>
> --

Hi dpb,

Thanks , Finally i made it with linear transformation using following formula.

value=((y(i) + abs(min(y)))/(max(y)-min(y)))*100

If you have also any other formula than let me know.