フィルターのクリア

Storing data from a function into and array to be recalled?

3 ビュー (過去 30 日間)
Joel Erdmann
Joel Erdmann 2019 年 11 月 20 日
編集済み: KALYAN ACHARJYA 2019 年 11 月 20 日
I am trying to record the following function and then be able to recall it.
clear all
clear
clc
a = arduino('com3', 'uno');
s = servo(a, 'D10','MaxPulseDuration', .0025, 'MinPulseDuration', .0005);
n = 60;
for k = 1:n;
z = readVoltage(a,'A5');
p = ((1023 / 5) * z);
x(n) = (p / 1023)
writePosition(s,x(n));
end
n = 60
for k = 1:n
writePosition(s,x(n))
end

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 11 月 20 日
編集済み: KALYAN ACHARJYA 2019 年 11 月 20 日
a = arduino('com3', 'uno');
s = servo(a, 'D10','MaxPulseDuration', .0025, 'MinPulseDuration', .0005);
n = 60;
x=zeros(1,n);
for k = 1:n
z=readVoltage(a,'A5');
p=((1023 / 5) * z);
x(k)=p/1023;
writePosition(s,x(n));
end
# Now you can recall the array x, when in required (same workspace)
for k=1:n
writePosition(s,x(k))
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Support Package for Arduino Hardware についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by