Can anyone pls tell me why I am getting the same plot instead of putting different values of H and B? The code is attached with this question for your kind perusal

2 Ansichten (letzte 30 Tage)
I am not getting the different plots for different valued of the H and B. Every row of the subplot has the same plot as of the first one of that row. can you Help me with this? the values I am putting are a=1,c=1,m=1,omega=5, T1=10, x0=1,v0=0.

Antworten (1)

Gaurav Sharma
Gaurav Sharma am 8 Okt. 2018
Bearbeitet: Walter Roberson am 2 Feb. 2019
RK:
function [OUT3,OUT4] = RK(A,M,B,C,OMEGA,T1,H,X0,V0) %RK Summary of this function goes here % Detailed explanation goes here
Y1=zeros(1,T1/H+1); Y2=zeros(1,T1/H+1); w=zeros (1,T1/H+1); Y1(1)=X0; Y2(1)=V0; w(1)=0;
for t=1:T1/H
K11=Y2(t);
K12=(-A/M)* abs(Y1(t))^B* (Y1(t)/abs (Y1(t)))+ C/M* cos (OMEGA*w(t));
K21= Y2(t)+ (H/2)* K12;
K22= (-A/M)* abs (Y1(t)+ (H/2)* K11)^B*((Y1(t)+ (H/2)* K11)/ abs (Y1(t)+ (H/2)* K11))+ (C/M)* cos(OMEGA *w(t));
K31= Y2(t)+ (H/2)* K22;
K32= (-A/M)* abs (Y1(t)+ (H/2)* K21)^B*((Y1(t)+ (H/2)* K21)/ abs (Y1(t)+ (H/2)* K21))+ (C/M)* cos(OMEGA *w(t));
K41= Y2(t)+ (H)* K32;
K42=(-A/M)* abs (Y1(t)+ (H/2)* K31)^B*((Y1(t)+ (H/2)* K31)/ abs (Y1(t)+ (H/2)* K31))+ (C/M)* cos(OMEGA *w(t));
Y1(t+1)= Y1(t)+H*((K11/6)+(K21/3)+(K31/3)+(K41/6));
Y2(t+1)= Y2(t)+H*((K12/6)+(K22/3)+(K32/3)+(K42/6));
w(t+1)=w(t)+H;
end
OUT3= Y1; OUT4=Y2; plot(w,Y1,w,Y2);
end

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by