I want to plot the summed (x(1)+x(3)​+x(5)+...x​(19)) vs time

3 次查看(过去 30 天)
此 个问题 已被 Star Strider 标记
clear all;
n = 10;
x=accumarray([2 3 n-1 n]',1);
B = toeplitz(x,x);
% G=graph(B);
% plot(G)
% Parameters
% matrixSize = 10; % Size of the matrix
numEdgesToRewire = 2; % Number of edges to rewire
% Create an initial matrix
% Y = B;
matrixSize=10;
% Randomly select two edges to rewire
edgesToRewire = randperm(matrixSize, numEdgesToRewire);
% Iterate through the edges to rewire
for i = 1:numEdgesToRewire
node1 = edgesToRewire(i);
node2 = randi([1, matrixSize]);
% Avoid rewiring to the same node or existing edges
while node2 == node1 || B(node1, node2) == 1
node2 = randi([1, matrixSize]);
end
% Rewire the edge
B(node1, node2) = 1;
B(node2, node1) = 1;
end
disp(B)
theta = 0.3;
dh = 2^-9;
dp = 2^-7;
phi = 3;
ita = 1;
y1 = [x(1); x(3); x(5); x(7); x(9); x(11); x(13); x(15); x(17); x(19)];
y2 = [x(2); x(4); x(6); x(8); x(10); x(12); x(14); x(16); x(18); x(20)];
i = 1;
f = [];
function xprime = kau(t, x, B)
nn = length(x); % Add this line to define nn
while i <= nn % Change this condition to include equal sign
f = [f; x(2*i-1)*(1 - theta*x(2*i-1)) - x(2*i) - (x(2*i-1)*x(2*i)) / (1 + x(2*i)) + dh*B*y1(i); ...
(phi*x(2*i-1)*x(2*i)) / (1 + x(2*i)) - ita*x(2*i) + dp*B*y2(i)];
i = i + 1; % Change this to increment i by 1
end
xprime = f; % Assign f to xprime
end
x0 = rand(1,20);
tspan=[0,1000];
[t, x] = ode45(@(t, x) kau(t, x, B), tspan, x0);

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by