listBoxの選択肢を変数から取得する方法
    2 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    SHromaneko
 le 26 Jan 2024
  
    
    
    
    
    Commenté : SHromaneko
 le 29 Jan 2024
            Matlab app designerにてListboxに表示する内容を変数から取得出来ますか?
エクセルファイルを読み込んでグラフを表示するアプリを作ろうと思います。
エクセルデータには大量のデータがあり、どのデータを表示するかを対話的に選択できるようにしたいです。
データの内容はエクセルファイルによって異なりますので、エクセルファイルの1行目に入っている計測データ名を取得し、それをリスト化することでどのデータを表示するかユーザーが選択できるようにしたいです。(下記のスクショのようなリスト変数txtを作成)
テキストの一行目の内容を変数に格納して、app.ListBox.Items = txtとすればいいのかと思いましたが、グレーの「編集不可」エリアになっているので出来なさそうです。
下記を実現する方法、もしくは代案何かありますでしょうか?
            % Create ListBoxLabel
            app.ListBoxLabel = uilabel(app.UIFigure);
            app.ListBoxLabel.HorizontalAlignment = 'right';
            app.ListBoxLabel.Position = [24 312 48 22];
            app.ListBoxLabel.Text = 'List Box';
            % Create ListBox
            app.ListBox = uilistbox(app.UIFigure);
            app.ListBox.Items = {'name1', 'name2'};
            app.ListBox.Position = [87 262 100 74];
            app.ListBox.Value = {};

0 commentaires
Réponse acceptée
  Hiroshi Iwamura
      
 le 26 Jan 2024
        Excelファイルを読み込む部分で、 app.ListBox.Items に、cell あるいは string 形式で入れれば大丈夫です
2 commentaires
  Atsushi Ueno
      
 le 27 Jan 2024
				自分で関数を作って(例えばstartupFcn)そこで処理をすれば良いです。これでうまくいきましたよ
methods (Access = private)
        % Code that executes after component creation
        function startupFcn(app)
            [filename,path] = uigetfile('*.xlsx');
            [num,txt,raw] = xlsread([path,filename]); % readtable, readmatrix, readcell 等に代えてね
            app.ListBox.Items = txt;
        end
    end

Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur スプレッドシート dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

