From: dpb on
nordmoon wrote:
> Well A(:,1)==401 produces a vector
>
> ans =
>
> 0
> 1
> 0
>
> And T=A(A(:,1)==401)
>
> T =
>
> 401
>
> But
>
> for i=1:length(B), c(i,1)=T(B(i,1));
> end
>
> add values in T for the different numbers in B ??
>
> I am sorry but I don't see what the error is other than it adds value
> that is not a matrix, T? How do I correct it?

I don't think you did what I suggested, precisely (but since you snipped
excessively, I'm not going to back and double-check).

What you want is first to select the rows that have the particular
value, then the corollary values associated w/ them. The problem is one
I overlooked and another is you didn't really do what I suggested
precisely. I overlooked that the for loop assumes only save the
auxiliary values whereas the : for the columns is all columns including
the first.

But, your testing of T=A(A(:,1)==401) didn't include the fix I suggested
to observe the problem of the first typo (but it should've given you a
clue as to what was wrong and how to fix it, particularly if you'd have
read the sample code carefully).

So,

T=A(A(:,1)==401, 2:4) % select auxiliary values for specific temp

Then the loop

for i=1:length(B), c(i)=T(B(i));

_will_ work for one row.

If there are multiple rows, then you'll need a double loop, the outer on
the number rows in T, the inner the above and C() will need to be sized
to be [nrows(T), length(B)]

--




First  |  Prev  | 
Pages: 1 2
Prev: Normalized matrix
Next: Ezplot constants?