Filtering through multiple vectors for a single set of values

1 次查看(过去 30 天)
I get the roots below using an equation solver & filtering out "unrealistic" roots with conditional/logical statements.
The part I'm stuck on is on how to code this proccess:
1) Identify the common integer at the beginning of the vector sets between Q1 - Q6 (in this case, 3)
2) Filter out the other vector sets (2,4)
3) Pull out the long decimal number from the #3 vector sets & assign that as the new Q1 Q2 etc
Q1 =
[ 2, 1, 1, 0.058437210716851634542028894189494]
[ 3, 1, 1, 0.058688566689220710419984397081727]
Q2 =
[ 2, 1, 1, 0.0098069127074167821263054682858129]
[ 3, 1, 1, 0.0078508603596354954926620927235173]
Q3 =
[ 2, 1, 1, 0.0015627892831483654579711058105059]
[ 3, 1, 1, 0.0013114333107792895800156029182727]
Q4 =
[ 2, 1, 1, 0.041562789283148365457971105810506]
[ 3, 1, 1, 0.041311433310779289580015602918273]
Q5 =
[ 3, 1, 1, 0.00083770632958521492732230435821]
[ 4, 1, 1, 0.020473081482478049769416844651268]
Q6 =
[ 3, 1, 1, 0.01083770632958521492732230435821]
[ 4, 1, 1, 0.030473081482478049769416844651268]
  2 个评论
Jacob Wood
Jacob Wood 2020-2-26
Will there always be a single integer that appears once in every Q_i?
Chad Williams
Chad Williams 2020-2-26
Yes it's purposely put there so the vector can be identified & only exists to point to the root. It will always be 1,2,3 & 4 for this application.
Below is the orginal output where you can see what would be 1 & 4 being filtered out as they are negative.
I just get stuck on trying to translate into code.
Q1 =
-0.15604402697446315680842658977416
0.058437210716851634542028894189494
0.058688566689220710419984397081727
-0.05986135947318542852737264354485
Q1 =
[ 2, 0.058437210716851634542028894189494]
[ 3, 0.058688566689220710419984397081727]

请先登录,再进行评论。

回答(2 个)

KSSV
KSSV 2020-2-26
1) Identify the common integer at the beginning of the vector sets between Q1 - Q6 (in this case, 3)
Read about unique for this.
2) Filter out the other vector sets (2,4)
Use ismember for this.
3) Pull out the long decimal number from the #3 vector sets & assign that as the new Q1 Q2 etc
You can use logical indexing for this.

Jacob Wood
Jacob Wood 2020-2-26
编辑:Jacob Wood 2020-2-26
Chad,
This might be a solution for you. It picks the most common root label and grabs all of them:
Q1 = [ 2, 1, 1, 0.058437210716851634542028894189494;
3, 1, 1, 0.058688566689220710419984397081727];
Q2 = [ 2, 1, 1, 0.0098069127074167821263054682858129;
3, 1, 1, 0.0078508603596354954926620927235173];
Q3 = [ 2, 1, 1, 0.0015627892831483654579711058105059;
3, 1, 1, 0.0013114333107792895800156029182727];
Q4 = [ 2, 1, 1, 0.041562789283148365457971105810506;
3, 1, 1, 0.041311433310779289580015602918273];
Q5 = [ 3, 1, 1, 0.00083770632958521492732230435821;
4, 1, 1, 0.020473081482478049769416844651268];
Q6 = [ 3, 1, 1, 0.01083770632958521492732230435821;
4, 1, 1, 0.030473081482478049769416844651268];
Q = [Q1;Q2;Q3;Q4;Q5;Q6];
select_int = mode(Q(:,1));
roots = Q(Q(:,1)==select_int,4);
  3 个评论
Jacob Wood
Jacob Wood 2020-2-26
I'm not sure I'm following. What is happening in these lines? Is this output from running the code?
[ 2, 0.058437210716851634542028894189494]
[ 3, 0.058688566689220710419984397081727]

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Filter Analysis 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by