Clear Filters
Clear Filters

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

2 views (last 30 days)
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 Comments
Adam Danz
Adam Danz on 3 Jan 2021
@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')

Sign in to comment.

Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!