how do i "re attach" string columns to data columns for identification?
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
when i input data, matlab always separates my string data( column headers and row id's) from the data it represents...i have been able to work around this because matlab keeps everything in place and it is easy to slap them back together outside of matlab... but i am working with data brushing and graphs, the databrushing retrieves the data values but not the row id...so how do i "link' my data with its original identifiers in Matlab???
1 个评论
Sean de Wolski
2013-12-19
Can you provide a small example?
回答(1 个)
Sean de Wolski
2013-12-19
If I understand you correctly, here is a small example:
x = rand(100,1);
y = rand(100,1);
names = char(randi(100,[100 3])+50); %random names
scatter(x,y);
%Do the brushing
%
% Brush your selection and then right-click, create variable, name it
% xbrush
%
[~,idx] = ismember(xbrush,[x y],'rows'); %locate them
names(idx) %extract names
11 个评论
john borsellino
2013-12-19
Sean de Wolski
2013-12-19
Well the cell array could hold your strings rather than the char that I had. How do you have the strings stored now?
To convert my names to a cell, just write
names = cellstr(names)
john borsellino
2013-12-19
john borsellino
2013-12-19
Sean de Wolski
2013-12-19
Don't use ans!! It's overwritten every time you do anything. Try my example first. Then change it to use idx (indices corresponding to brushed points) into your column of ids.
john borsellino
2013-12-19
Sean de Wolski
2013-12-19
So data is a cell array?
Are you using R2013b by any chance?
john borsellino
2013-12-19
john borsellino
2013-12-19
john borsellino
2013-12-19
Sean de Wolski
2013-12-20
Just attach your file and the code you're using right now.
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!