App Designer Time-Steps and Velocity data from excel for motor control

2 次查看(过去 30 天)
Hello,
I read datas from a excel file: x-column is "time" and y-column is "velocity" and plot them. Everything is ok.
e.g. Start:
0s 0prm
20s 200rpm
40s 250rpm
80s 300prm
......
Now I would like to give my motor control the new velocity after the time is over depends on my table data. Maybe you know an advice how I can do it? Thanks a lot
t = readtable("Daten.xlsx","Sheet",2);
x = table2array(t(:,1));
y = table2array(t(:,3));
stairs(app.UIAxes,x,y,'-o');
  3 个评论
Adam Danz
Adam Danz 2021-1-3
@Chris are you asking how to add data to the table or how to extrapolate a velocity estimate given a future time?
If your goal is to do the latter, you'll need to provide more info about how you expect the velocity to change. For example, if you expect a simple logrithmic growth (for demo purposes only),
x = [0 20 40 80];
y = [0 200 250 300];
clf()
hold on
grid on
plot(x,y,'b-o','DisplayName','RawData')
z = lsqcurvefit(@(p,xdata)p(1)+p(2).*log(xdata),[0,1],x(2:end)',y(2:end)');
Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance.
newX = 5:100;
newY = z(1)+z(2).*log(newX);
plot(newX, newY, 'k--','DisplayName','Fit')
legend('Location','SouthEast')

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by