How to populate matlab GUI edit texts with values from MySQL database?

조회 수: 1 (최근 30일)
hush puppy
hush puppy 2015년 5월 7일
답변: Piyush Kumar 2024년 10월 21일
I have created a table with 10 columns in MySQL and manage to connect it with Matlab. What is the code to retrieve those data and display them in a matlab GUI edit texts boxes?
  댓글 수: 2
BSantos
BSantos 2015년 5월 7일
Do you have Database Toolbox installed in your computer?
hush puppy
hush puppy 2015년 5월 8일
Yup, so what do I do next? Sorry, I'm new to MATLAB.

댓글을 달려면 로그인하십시오.

답변 (1개)

Piyush Kumar
Piyush Kumar 2024년 10월 21일
Hi,
To retrieve data from the database, you can use the fetch function.
If you have created the edit text box using uicontrol, you can use the set function to display the value extracted from the database.
For example,
fig = figure('Position', [100, 100, 300, 200], 'Name', 'Simple GUI');
% Create an edit text box
editText = uicontrol('Style', 'edit', ...
'Position', [50, 100, 200, 40], ...
'String', 'Default value');
% db_value = fetch(conn, sqlquery) % Replace conn and sqlquery with the correct values
db_value = 'Hi, I am from db'
% Set the string value of the edit text box
set(editText, 'String', db_value);

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by