Using a loaded table in the main program in a function

10 ビュー (過去 30 日間)
Kshitij D
Kshitij D 2017 年 3 月 9 日
コメント済み: Kshitij D 2017 年 3 月 10 日

I have the user of my matlab program load a table and my code reads the values for certain properties (stored in columns) from the table. I wrote a Matlab function that would interpolate the values from the table.

function [rho_o,B_o,mu_o,Rso] = oil_prop_sat(Po)

rho_o=interp1(Po_data(1:10),rho_o_data(1:10),Po,'linear');

B_o=interp1(Po_data(1:10),B_o_data(1:10),Po,'linear');

mu_o=interp1(Po_data(1:10),mu_o_data(1:10),Po,'linear');

Rso=interp1(Po_data(1:10),Rso_data(1:10),Po,'linear');

But when I try and use the function into the main program, it gives my the error Undefined function or variable 'Po_data'. I understand that because I am not loading the data into the function, hence it is unable to find anything named Po_data. But I don't want the user to reinput the table every time I have to run the function (which is a lot of times).

回答 (1 件)

Image Analyst
Image Analyst 2017 年 3 月 9 日
You can retrieve the data from the uitable from any callback function that has access to the handle of the uitable, which means any callback functions of any controls you placed on the GUi with GUIDE.
Po_data = handles.uitable1.Data; % uitable1 is the table where the user entered Po_data.
  1 件のコメント
Kshitij D
Kshitij D 2017 年 3 月 10 日
would this be included in the function or the main program?

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

カテゴリ

Help Center および File ExchangeDevelop 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