Hi fellow experts,
I'm trying to design a matlab GUI where the user can key in the desired value in the display box which will display the output of the Arduino in graph. eg. if i key in 3 on the display box, the graph will show the output of the Arduino in 180 seconds. I am currently stuck at this stage as the For loops at b=2 would keep overlapping with b=1.
a=arduino
b = get(handles.edit1, 'String')
for b=1;
for d=1:60
temp(d)= readVoltage(a,'A15');
plot(temp);hold on;
pause(0.2);
end
end
for b=2;
for i=1:120
temp(i)= readVoltage(a,'A15');
plot(temp);hold on;
pause(0.2);
end
end
etc.
Any form of help would be greatly appreciated!!
Thanks
Jacob

回答 (1 件)

dpb
dpb 2018 年 3 月 17 日
編集済み: dpb 2018 年 3 月 18 日

0 投票

b = get(handles.edit1, 'String')
N=int(str2num(b)*60);
temp=zeros(N,1);
for d=1:N
temp(d)= readVoltage(a,'A15');
plot(temp);hold on;
pause(0.2);
end

2 件のコメント

Chong Kai Xiang
Chong Kai Xiang 2018 年 3 月 18 日
Hi
i tried with your solution and it came out as
Undefined operator '*' for input arguments of type 'cell'.
Image Analyst
Image Analyst 2018 年 3 月 18 日
編集済み: Image Analyst 2018 年 3 月 18 日
b is a cell array because it's more than 1 line. So after you get b, try
b = b{1};
or
b = char(b);
If you really want for loops to run simultaneously, you'd need the Parallel Processing Toolbox and use the parfor command instead of the for command.

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

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2018 年 3 月 17 日

編集済み:

2018 年 3 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by