How to plot function x(2)=-1/2*x(1)+t?
clc;
clear;
close;
x1=3+3/8;
u=8;
teta(1)=0;
%teta(u+2)=0.2;
for i=1:u
teta(i+1)=i/5;
end
for j=1:1
for k=1:u
%initial_func=[x1,x2];
[t,x] = ode45(@IJP4,[teta(k):0.0001:teta(k+1)], x1(j));%
n=length(t);
%disp(size(x));
x1(j)=x(n,1)+4*x(n,1);
hold on
%view(30,15);
x(2)=-1/2*x(1)+t;
hold on
figure(1)
subplot(2,1,1);
plot(t,x(:,2),’color’,’g’,’Linewidth’,1.2);
xlabel(‘bf t’); ylabel(‘$$z$$’,’interpreter’,’latex’,’fontsize’,16); zlabel(‘bf psi_2’);
grid on
hold on
subplot(2,1,2);
plot(t,x(:,1),’color’,’g’,’Linewidth’,1.2);
xlabel(‘bf t’); ylabel(‘$$y$$’,’interpreter’,’latex’,’fontsize’,16); zlabel(‘bf psi_3’);
grid on
hold on
figure(2)
plot3(t,x(:,1),x(:,1),’g’);
xlabel(‘$$t$$’,’interpreter’,’latex’,’fontsize’,16)
%ylabel(‘phi_{2}’,’fontsize’,16)
ylabel(‘$$z$$’,’interpreter’,’latex’,’fontsize’,16)
zlabel(‘$$y$$’,’interpreter’,’latex’,’fontsize’,16);
grid on
hold on
end
end
function dx=IJP4(t,x)
dx=zeros(1,1); % создает нулевой вектор-столбец
dx(1)=-3/2*x(1)-6*x(1);
endclc;
clear;
close;
x1=3+3/8;
u=8;
teta(1)=0;
%teta(u+2)=0.2;
for i=1:u
teta(i+1)=i/5;
end
for j=1:1
for k=1:u
%initial_func=[x1,x2];
[t,x] = ode45(@IJP4,[teta(k):0.0001:teta(k+1)], x1(j));%
n=length(t);
%disp(size(x));
x1(j)=x(n,1)+4*x(n,1);
hold on
%view(30,15);
x(2)=-1/2*x(1)+t;
hold on
figure(1)
subplot(2,1,1);
plot(t,x(:,2),’color’,’g’,’Linewidth’,1.2);
xlabel(‘bf t’); ylabel(‘$$z$$’,’interpreter’,’latex’,’fontsize’,16); zlabel(‘bf psi_2’);
grid on
hold on
subplot(2,1,2);
plot(t,x(:,1),’color’,’g’,’Linewidth’,1.2);
xlabel(‘bf t’); ylabel(‘$$y$$’,’interpreter’,’latex’,’fontsize’,16); zlabel(‘bf psi_3’);
grid on
hold on
figure(2)
plot3(t,x(:,1),x(:,1),’g’);
xlabel(‘$$t$$’,’interpreter’,’latex’,’fontsize’,16)
%ylabel(‘phi_{2}’,’fontsize’,16)
ylabel(‘$$z$$’,’interpreter’,’latex’,’fontsize’,16)
zlabel(‘$$y$$’,’interpreter’,’latex’,’fontsize’,16);
grid on
hold on
end
end
function dx=IJP4(t,x)
dx=zeros(1,1); % создает нулевой вектор-столбец
dx(1)=-3/2*x(1)-6*x(1);
end clc;
clear;
close;
x1=3+3/8;
u=8;
teta(1)=0;
%teta(u+2)=0.2;
for i=1:u
teta(i+1)=i/5;
end
for j=1:1
for k=1:u
%initial_func=[x1,x2];
[t,x] = ode45(@IJP4,[teta(k):0.0001:teta(k+1)], x1(j));%
n=length(t);
%disp(size(x));
x1(j)=x(n,1)+4*x(n,1);
hold on
%view(30,15);
x(2)=-1/2*x(1)+t;
hold on
figure(1)
subplot(2,1,1);
plot(t,x(:,2),’color’,’g’,’Linewidth’,1.2);
xlabel(‘bf t’); ylabel(‘$$z$$’,’interpreter’,’latex’,’fontsize’,16); zlabel(‘bf psi_2’);
grid on
hold on
subplot(2,1,2);
plot(t,x(:,1),’color’,’g’,’Linewidth’,1.2);
xlabel(‘bf t’); ylabel(‘$$y$$’,’interpreter’,’latex’,’fontsize’,16); zlabel(‘bf psi_3’);
grid on
hold on
figure(2)
plot3(t,x(:,1),x(:,1),’g’);
xlabel(‘$$t$$’,’interpreter’,’latex’,’fontsize’,16)
%ylabel(‘phi_{2}’,’fontsize’,16)
ylabel(‘$$z$$’,’interpreter’,’latex’,’fontsize’,16)
zlabel(‘$$y$$’,’interpreter’,’latex’,’fontsize’,16);
grid on
hold on
end
end
function dx=IJP4(t,x)
dx=zeros(1,1); % создает нулевой вектор-столбец
dx(1)=-3/2*x(1)-6*x(1);
end index in position 2 exceeds array bounds (must not MATLAB Answers — New Questions