i wrote simple code for read analog pin in arduino and plot the signal and i want to wrote simple code in GUI. i want to do just simple pushbutton and signal figure in side of it. when i clik pushbutton i want it to draw. how can i do this ?
help me please
here is my code;
clc; close all; clear all;
delete(instrfind(('Port'),('COM5')));
a=arduino('COM5');
tic;
i=0;
while toc<150
i=i+1;
time(i)=toc;
v(i)=readVoltage(a,'A0');
plot(time,v,'r')
drawnow
end

 채택된 답변

Walter Roberson
Walter Roberson 2016년 5월 7일

0 개 추천

Delete that first line, the clc and so on. Put the rest within a callback of a uicontrol. See GUIDE to create a simple GUI

댓글 수: 4

halil isik
halil isik 2016년 5월 8일
ok how can i get 'toc' value from edit text
howlong = str2double(get(handles.edit1, 'String'));
while toc < howlong
...
end
thanks for your helps :) but i want to ask one more thing.
how can i change plot color with listbox ?
i tried this in callback but did not work.
ciz_renk=get(handles.listbox1,'value');
switch ciz_renk
case 1
set(hline,'color','b');
case 2
set(hline,'color','r');
case 3
set(hline,'color','g');
end
That should work as long as hline is the line handle and you make the change after you draw the line.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

질문:

2016년 5월 7일

댓글:

2016년 5월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by