How to create a vector whose elements are functions of a variable?
Mostra commenti meno recenti
I am working on a project and let me explain the situation quick:
We are testing different motors given a specific torque requirement. For each motor we have specified the characteristic torque-speed curve (a straight line). We are using ode45 dolver for the complex dynamics taking place in our system.
PROBLEM: Imagine the torque-speed line to be having negative gradient, starting from an initial value (stall torque) and as rotational velocity increases, torque decreases. However, once torque becomes zero it has to stay zero (no negative values). ODE45 does not accept piecewise function inputs. Hence, i approximated the line with a fourier series.
PROBLEM 2: I figured out the Fourier expansion, but I cannot make it work in Matlab.
Please help
NOTE: I used n = 1:10 rather than infinity - its good approx
Tmd = motor torque during convertible roof deployment
dphi = angular velocity of motor (rad/s)
Nmmaxd = Maximum (terminal) rotational velocity in rpm (rounds/mnute)
Suppose my function is correct. How can I save the values? The error when running the code says:
for n = 1:10
TmdFOURIER_TERM(n) = @(dphi) (2/(n*pi))*(1-cos(n*pi/3))*cos((n*10/Nmmaxd)*dphi);
end
Tmd = @(dphi) Tm0d/6 + sum(TmdFOURIER_TERM);
Nonscalar arrays of function handles are not allowed; use cell arrays instead.
Error in Mattedit_2 (line 67)
TmdFOURIER_TERM(n) = @(dphi) (2/(n*pi))*(1-cos(n*pi/3))*cos((n*10/Nmmaxd)*dphi);
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!