How to create multiple index with sqlalchemy?

MATLAB: Quick way to reference an index of values inside one array column like blitzer(:,5) without having to create an entirely new vector?

  • I want to reference an index of values inside the 5th column of an array like blitzer. E.g. I want to access, say, all values of blitzer(:,5) where blitzer(:,4) < 10. This outputs an index of values. So maybe I could set blitzer5 = blitzer(:,5), and then call blitzer5(blitzer(:,4) < 10). But is there a quick way to do this without having to create an entirely new vector? Ideally I'd like to call blitzer(:,5)[blitzer(:,4) < 10]. If so, how?

  • Answer:

    Yes, just remember that the inequality simply yields a linear index, which can be used to replace ":" in the first dimension of your matrix. >> blitzer=rand(5,5) blitzer = 0.8147 0.0975 0.1576 0.1419 0.6557 0.9058 0.2785 0.9706 0.4218 0.0357 0.1270 0.5469 0.9572 0.9157 0.8491 0.9134 0.9575 0.4854 0.7922 0.9340 0.6324 0.9649 0.8003 0.9595 0.6787 >> blitzer(blitzer(:,4)<0.5,5) ans = 0.6557 0.0357 >> blitzer(:,4)<0.5 ans = 1 1 0 0 0

Achilleas Vortselas at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.