How to display continuous changing values in static text of GUI

2 ビュー (過去 30 日間)
Chandra Shekhar
Chandra Shekhar 2013 年 3 月 20 日
回答済み: suvarna patil 2019 年 2 月 28 日
here i am receiving values from serial port and then i am separating text part from received data.
when i separate text, then i need to display in static text on GUI. here i used code which displays the value after completing the loop. here i considered loop is 6 times, it means i am reading 6 values from serial port.but it will display only last value(after completing loop).
Here is the push button code please any one tell me what to modify.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
delete(instrfindall)
ser=serial('COM4','BaudRate',9600);
fopen(ser)
count=0;
for i=1:6
da=fscanf(ser);
cond=isempty(da);
if cond==0
count=count+1;
end
if count==3
set(handles.text1,'string',da);
count=0;
end
end
  1 件のコメント
Michel de Jongh
Michel de Jongh 2016 年 7 月 23 日
Did you got your code to work?
If so, is it possible to share the code? I'm working on a similair project but I'm having a hard time to figure out where to start.
Kind regards.

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

回答 (3 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 20 日
Change the last condition
if count==3
str=get(handles.text1,'string')
set(handles.text1,'string',[str da]);
count=0;
end
  1 件のコメント
Chandra Shekhar
Chandra Shekhar 2013 年 3 月 20 日
Thank you Azzi,
my received data not in same length and i want to display only current received text,but it is appending with previous text.
if received data is more than 3 times it giving error like
CAT arguments dimensions are not consistent.

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


Elias Gule
Elias Gule 2016 年 4 月 1 日
I think your code is working fine. Try putting a little time delay before setting the string of handles.text1. Something like,
if count == 3
pause(1) ; % 1 second time delay
set(handles.text1,'string',da);
count=0;
end

suvarna patil
suvarna patil 2019 年 2 月 28 日
How to display 4 continuous changing ADC values in 4 differnt text box in GUI. ?? Can anyone help out..

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by