フィルターのクリア

How can I use splitapply() in matlab appdesigner?

4 ビュー (過去 30 日間)
Muazma Ali
Muazma Ali 2024 年 2 月 11 日
コメント済み: Cris LaPierre 2024 年 2 月 12 日
Hi! :)
I have matlab 2018 and really dont want to upgrade to newer versions right now.
What I was wondering was whether anybody could show with an easy example how I can apply splitapply() to group my data in a 2 dimensional plot. Earlier I have seen a post regarding this issue but I didnt understand how to do that..
I have a heterogenous table osmotic data and I want to group my 2 d plot with the text data showing the bestsalts which is a colum containing two salts each row, like CaCl2 NaCl , ZnBr2 KCl
  1 件のコメント
Matt J
Matt J 2024 年 2 月 11 日
If you provide some example data and the desired result, then perhaps.

サインインしてコメントする。

回答 (1 件)

Cris LaPierre
Cris LaPierre 2024 年 2 月 11 日
編集済み: Cris LaPierre 2024 年 2 月 11 日
You could use a differnt function that incorporates grouping, like gscatter.
load carsmall
gscatter(Displacement,Horsepower,Model_Year)
To specifically use splitapply, create an anonymous function with your plotting command. Something like this (I'm specivically trying to duplicate gscatter here).
figure
hold on
[G,ID] = findgroups(Model_Year);
splitapply(@(x)plot(x(:,1),x(:,2),'.','MarkerSize',20),[Displacement,Horsepower],G)
legend(string(ID),'Location','best')
  1 件のコメント
Cris LaPierre
Cris LaPierre 2024 年 2 月 12 日
Here's what the actual callback funciton might look like. I'm assuming the data to plot is a property of the app. See this page if you don't know what that means:
function ButtonPushed(app, event)
hold(app.UIAxes,"on")
[G,ID] = findgroups(app.Model_Year);
splitapply(@(x)plot(app.UIAxes,x(:,1),x(:,2),'.','MarkerSize',20),[app.Displacement,app.Horsepower],G);
legend(app.UIAxes,string(ID),'Location','best')
end

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by