MATLAB Answers

graph won't appear

3 views (last 30 days)
Gianne Ong
Gianne Ong on 13 May 2021
>> zi = 0.2; % define the value of damping coefficient
>> r = 0:0.05:10; % define the range of r
>> for i = 1; % length(r)
>> T(i) = sqrt(1+(4*(zi^2)*(r(i)^2))) / sqrt(((1-r(i)^2)^2)+(4*(zi^2)*(r(i)^2)));
>> end
>> plot (r,T); % plot T vs r

Answers (2)

Daniele Sonaglioni
Daniele Sonaglioni on 13 May 2021
Try this code. You have forgotten to specifay the indices in the for cicle
zi = 0.2; % define the value of damping coefficient
r = 0:0.05:10; % define the range of r
for i = 1:length(r); % length(r)
T(i) = sqrt(1+(4*(zi^2)*(r(i)^2))) / sqrt(((1-r(i)^2)^2)+(4*(zi^2)*(r(i)^2)));
end
plot (r,T); % plot T vs r
  1 Comment
Daniele Sonaglioni
Daniele Sonaglioni on 20 May 2021
If this answer helped you, please accept it.

Sign in to comment.


VBBV
VBBV on 13 May 2021
%if true
zi = 0.2; % define the value of dam
r = 0:0.05:10; % define the range
T = sqrt(1+(4*(zi^2)*(r.^2)))./ sqrt(((1-r.^2).^2)+(4*(zi^2)*(r.^2)));
plot (r,T); % plot T vs r
You can plot the equation without for loop using element wise operator

Products

Community Treasure Hunt

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

Start Hunting!