필터 지우기
필터 지우기

Can I use splitapply with two grouping variables and how can it be done in matlab app designer?

조회 수: 4 (최근 30일)
Hi ! :)
I am referring to this example:
load carsmall
whos
Name Size Bytes Class Attributes Acceleration 100x1 800 double Cylinders 100x1 800 double Displacement 100x1 800 double Horsepower 100x1 800 double MPG 100x1 800 double Mfg 100x13 2600 char Model 100x33 6600 char Model_Year 100x1 800 double Origin 100x7 1400 char Weight 100x1 800 double ans 1x1 8 double cmdout 1x33 66 char gdsCacheDir 1x14 28 char gdsCacheFlag 1x1 8 double i 0x0 0 double managers 1x0 0 cell managersMap 0x1 8 containers.Map
[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

답변 (1개)

Cris LaPierre
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 CenterFile 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!

Translated by