How to get specified data in table
显示 更早的评论
Please help me.
How can i filter the table by specified 'Pushover-x' as a rownames and only vartype 'StepNum' , 'GlobalFX', 'GlobalFZ' data which i want to get.

采纳的回答
Where T is your table:
idx = strcmpi(T.OutputCase,'Pushover-x');
out = T(idx,{'StepNum','GlobalFX','GlobalFZ'})
Note that if OutputCase really were the RowNames then you could have done this:
out = T('Pushover-x',{'StepNum','GlobalFX','GlobalFZ'})
6 个评论
hey thanks a lot. I've learned from you. But what if i want multiple filter ? I already did but i think it is not shortway. Do you have any idea, how to make it simple ?
this is my code :

jointdisplacement = array2table(TableData,"VariableNames",FieldKeysIncluded)
idx = strcmp(jointdisplacement.Joint,'5')
out = jointdisplacement(idx,{'OutputCase','StepNum','U1'})
idx2 = strcmp(out.OutputCase,'Pushover-x')
out2 = out(idx2,{'StepNum','U1'})
"But what if i want multiple filter ?"
You can combine multiple logical vectors using &. For example where T is your table:
idx = strcmp(T.Joint,'5') & strcmp(T.OutputCase,'Pushover-x');
out = T(idx,{'StepNum','U1'})
thanks a lot
idx = strcmp(T.Joint,'5') & strcmp(T.OutputCase,'Pushover-x') & strcmp(T.OutputCase,'MODAL');
out = T(idx,{'StepNum','U1'})
but it was error... so it cant take two filters in one variable ?
"but it was error"
Then you need to tell us exactly what the error is. Show us all of the red text.
"so it cant take two filters in one variable ?"
MATLAB does not limit how many AND operators can be chained one after another.
But your logic using AND is most likely incorrect: can you show one single value of the OUTPUTCASE field whose value is both equal to "Pushover-X" and also to "MODAL" ? That is what AND means.
I am guessing that you intended to use OR:
idx = strcmp(T.Joint,'5') & (strcmp(T.OutputCase,'Pushover-x') | strcmp(T.OutputCase,'MODAL'));
or perhaps ISMEMBER or MATCHES or similar:
idx = strcmp(T.Joint,'5') & ismember(T.OutputCase,{'Pushover-x','MODAL'});
thanks stephen, ismember was the result
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
标签
另请参阅
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
