Can I use splitapply with two grouping variables and how can it be done in matlab app designer?
2 次查看(过去 30 天)
显示 更早的评论
Hi ! :)
I am referring to this example:
load carsmall
whos
[g,id]=findgroups(Model_Year);
hAx=axes; hold(hAx,'on')
splitapply(@(x,y)scatter(x,y,'filled'),Displacement,Horsepower,g)
legend(hAx,"Model Year "+string(1900+id),'location','northwest')
xlabel('Displacement'), ylabel('Horsepower')
--------------------------------
I have a table which is heterogenous. And I want to show the names of the first preferred salt user has chosen and second preferred salt (these are two of the column in my table) along with their properties on the x and y axis. Their properties are also the different columns in my table
0 个评论
回答(1 个)
Cris LaPierre
2024-5-20
Yes, you can use two grouping variables. However, the output is still an Nx1 vector of the unique groups (combination of the grouping variables).
load carsmall
[g,id1,id2]=findgroups(Model_Year,Cylinders);
hAx=axes; hold(hAx,'on')
splitapply(@(x,y)scatter(x,y,'filled'),Displacement,Horsepower,g)
legend(hAx,string(1900+id1) + ", "+string(id2) +" #Cyl",'location','northwest')
xlabel('Displacement'), ylabel('Horsepower')
The code should work in app designer. Just update your target axes to be app.UIAxes (or whatever you named your axes component).
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!