Am Montag, 26. Juli 2010 14:56:48 schrieb dirac:
> Hi thanks for the reply,
>
> I see how this can work, but I am having problems with my data. The problem
> I think is that I have a matrix which I pre-defined as zeros, then replaced
> by numbers from a for loop calculation. I don't know how many rows I will
> be using in the calculation (in the for loop) so I pre allocated more than
> enough...Could this be a problem? Should I remove the zeros on the end of
> the vector with the indecies in?
>
> Also could I have something like:
>
> a=[1:10]
> b=matrix
> col=some pre defined column from the matrix
> plot(a(1:length(b),col))
>
> it is b that has the zeros and indecies in.
>
> Sorry if this isn't very clear!
>
> Thanks
> Martin
>
> -----
> Pretty much convinced Octave>Excel for scientific data analysis!
>
If I understand this correctly and you want to use a column of the matrix for
the index it should read like this
plot(a(b(:, col)))
b(:, col) extracts the column number col from the matrix (so the result is a
vector of indexes).
Remark: I would remove the trailing zeros or if you don't want that and have
for example the value
m = number of nonzero values in the column
you can also do
plot(a(b(1:m, col)))
otherwise you will have an error like this (if index 0 is accessed)
error: subscript indices must be either positive integers or logicals.
- mh
_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave