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 个评论
回答(2 个)
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.
0 个评论
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
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 Center 和 File Exchange 中查找有关 Filter Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!