How can I plot graph using external function?
Ältere Kommentare anzeigen
I am trying to plot this equation.

I have the values of B, omega_d, zeta, N_k and t_j is the multiples of 1.89.
First, I tried make an external function to represent the equation including sigma and deduce a function about t. Then tried to draw a gragh for t in conclution.
But I am struggling with where to define t_j, call the external function, and making a function about t and plotting it. It's the code that I wrote below.(there will be lots of errors but don't know how to fix it..)
Any comment will be helpfull. Please help, thanks!
<plotting>
clc; clear;
t=0:10;
sum=s(t)
figure(1)
fplot(s, [1,10])
<s.m>
function [sum]= s(t)
B_n=-5.36 ;
omega_d= 400;
zeta=29 ;
N_k=10;
% sum=zeros(1,N_k);
for i=1:N_k
t_j= 1.89.*i;
sum= sum+ exp(-(zeta/2).*(t-t_j)).*(-zeta*(sin(omega_d/2.*(t-t_j)))+ omega_d.*cos(omega_d/2*(t-t_j)));
end
sum=B_n/omega_d.*sum;
end
1 Kommentar
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
