MATLAB Answers

Invalid text character. Check for unsupported symbol, invisible character, or pasting of non-ASCII characters.

644 ビュー (過去 30 日間)
Nga Thede
Nga Thede 2020 年 4 月 10 日
回答済み: Walter Roberson 2020 年 4 月 10 日
I really don't know what is the reason for this error. PLease help!
theta_dd(i)= (kP*r(i) +kD*r_dot(i) -(m*g*l+kP)*sin(theta(i)) -kD*theta_dot(i))/M;

  0 件のコメント


回答 (2 件)

Walter Roberson
Walter Roberson 2020 年 4 月 10 日
theta_dd(i)= (kP*r(i) +kD*r_dot(i) -(m*g*l+kP)*sin(theta(i)) -kD*theta_dot(i))/M;
Right after the semi-colon you have char(8203) which us U+200b which is "zero width space".
Put your cursor on the semi-colon and press shift and right arrow several times until your cursor is positioned on the next line. That should highlight several characters. Type in ; and then return. This process should get rid of the zero-width space.

  0 件のコメント


James Browne
James Browne 2020 年 4 月 10 日
編集済み: James Browne 2020 年 4 月 10 日
It is impossible to debug your one line of code because I can't run it on my end due to undefined variables. However, if you copied and pasted that line of code into MATLAB, it is likely that there is some text character(s) in the line that you copied which matlab does not recognize.
If you did copy and paste the code, try typing it in by hand instead. Otherwise you will need to post the whole code before anyone can really help you.

  2 件のコメント

Nga Thede
Nga Thede 2020 年 4 月 10 日
I thought the same at first so I retype it. However, I could be dead wrong, here is my full code
clear all; clc;
l= 1; %m lenght of the rod
m=5; %kg mass of the pendulum
J= 1.25; %kgm^2 at the pivot point
z= 0.707; %damping ratio
wn=2*pi; %rad/s bandwitch at z=0.707
M=J+m*l^2; %Total inertia
kD=2*z*wn*M %Derivative control gain
kP=M*wn^2-m*g*l %Proportional control gain
wd=wn*sqrt(1-z^2); %imaginary part of s
% Part e
% Plot response with non-linear system
v(1)=0; %start from rest
theta(1)=20*pi/180; %start from rest at 20 degrees
r(1)=0; %desired position starting at 0 degree
% Numerical intergration
for i=1:tmax
theta_dd(i)= (kP*r(i) +kD*r_dot(i) -(m*g*l+kP)*sin(theta(i)) -kD*theta_dot(i))/M;
title('Theta vs Time ')
xlabel('Time (s)')
ylabel('Theta (rad)')
Nga Thede
Nga Thede 2020 年 4 月 10 日
The only line it said error is the line I posted above which I don't understand why cause I tried to retyped the whole line already and still saying the same thing.


Community Treasure Hunt

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

Start Hunting!

Translated by