Categorizing range of data
显示 更早的评论
Hello,
I am using vector coding to analyze coordination patterns during arm reaching, which the values are from 0 to 360. I've used an if statement to attempt to categorize each value along 1:99 normalized time points on variable phsangSE so that I can eventually get a frequency of each category in the new variable coupAng. The return in coupAng is <undefined> on all time points except the last one, which it correctly categorizes. I'm not sure where the issue is in the code, but loops aren't my strongest suit at the moment, so any help is great. Or, if there is a better way to categorize the data I'm all ears.
Thank you in advance!
coupAng = categorical(nan(1,99),1:4,["Proximal Segment Phase","In-Phase","Distal Segment Phase","Anti-Phase"]);%nan(1,99),1:4,
for i = length(phsangSE)
if phsangSE(i) < 22.5 || phsangSE(i) >=157.5 && phsangSE(i) < 202.5 || phsangSE(i) >=337.5 && phsangSE(i) <= 360
coupAng(i) = ["Proximal Segment Phase"];
elseif phsangSE(i) >= 22.5 && phsangSE(i) < 67.5 || phsangSE(i) >= 202.5 && phsangSE(i) < 247.5
coupAng(i) = ["In-Phase"];
elseif phsangSE(i) >= 67.5 && phsangSE(i) < 112.5 || phsangSE(i) >= 247.5 && phsangSE(i) < 292.5
coupAng(i) = ["Distal Segment Phase"];
elseif phsangSE(i) >=112.5 && phsangSE(i) < 157.5 || phsangSE(i) >=292.5 && phsangSE(i) < 337.5
coupAng(i) = ["Anti-Phase"];
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Get Started with MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!