- tf is a scalar whose value is 20. Why indexing?
- num1 has all elements which are fractions and you cannot use them as indexing.
- den1 also all the elements which are fractions.
Index in position 1 is invalid. Array indices must be positive integers or logical values. can anyone help me solve the problem?
8 ビュー (過去 30 日間)
古いコメントを表示
this is a code of electromechanic system , when I run it without writing transfer function code (T_1 , T_2 , ... ) ,it runs . but when I write transfer function it errors. can you help me solve this problem?
x0=[0;0;0];
t0=0;
tf=20;
global k_m J_m J R L N k_t;
k_m=0.05; %constant
R=1.2; %ohm
L=0.05; %henry
J_m=8e-4; %Moment of inertia on the motor side
J=2e-2; %Moment of inertia on the load side
N=12; %constant
k_t=50 ; %N/m
J_e=J+(N^2*J_m);
A=[0 1 0; N^2*k_t/J_e 0 N*k_m/J_e; 0 -N*k_m/L -R/L];
B=[0 0;0 -1/J_e; 1/L 0];
C=[1 0 0 ; 0 1 0];
D=zeros(2,2);
G=ss(A,B,C,D);
[num1,den1]=ss2tf(A,B,C,D,1);
[num2,den2]=ss2tf(A,B,C,D,2);
T_1=tf(num1(1,:),den1);
T_2=tf(num1(2,:),den1);
T_3=tf(num2(1,:),den2);
T_4=tf(num2(2,:),den2);
%% functions
function [xdot]=electromechanic(t,x)
global k_m J J_m R L N k_t ;
J_e=J+(N^2*J_m);
%x1=teta ; x2=omega ; x3=i;
v=2; %voltage
T_L=5 ;%load torque
u_1=v; %first input
u_2=T_L;%second input
xdot=zeros(3,1);
xdot(1)=x(2);
xdot(2)=(N^2*k_t/J_e)*x(1)+(N*k_m/J_e)*x(3)-(1/J_e)*u_2;
xdot(3)=(-N*k_m/L)*x(2)-(R/L)*x(3)+(1/L)*u_1;
end
0 件のコメント
採用された回答
KSSV
2021 年 1 月 17 日
T_1=tf(num1(1,:),den1);
The above line is ridiculous. Points to note:
So whn you index, you should use the indices as either logicals or posittive integers. In your case, the indices are fractions which is wrong. Also you need to index for arrays not for scalars.
3 件のコメント
wassim bidi
2021 年 1 月 17 日
Answer me please.
Excuse me,i can't ask
so, i have porblem and i need to help
the problm with :Error using plot
Vectors must be the same lengths.
clc
clear
sys1 = tf(1,[0.1 1])
t=0:0.1:10;
step(sys1)
y=step(sys1);
plot(t,y)
Steven Lord
2021 年 1 月 17 日
Tina M:
While the variable tf exists you will not be able to call the tf function. Attempts to call the function will be interpreted instead as an attempt to index into the variable.
Rename or remove that variable.
wassim bidi:
This question is not related to Tina M's original question. Please post it as a separate question (using the Ask link just below the blue bar at the top of this page.)
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!