How to define a continuous range?

33 ビュー (過去 30 日間)
Yuhong Jin
Yuhong Jin 2019 年 11 月 27 日
回答済み: Chidvi Modala 2020 年 1 月 3 日
Here I defined a range for dy from 0.5 to 5 using
dy = 0.5:0.1:5
The script works slowly and need to wait for a long time for it to produce a graph
If I used another way like below trying to define a continuous range:
dy >=0.5 & dy <=5
or
dy >=0.5 && dy <=5
Matlab produces errors saying
Invalid use of operator.
My full script is below:
syms x1 y1 x2 y2
i=1;
for dy=0.5:0.1:5
M(i,1) = dy;
f = [5.*x1-6.*y1+1+0.5.*(x2-x1), 6.*x1-7.*y1+1+dy.*(y2-y1), 5.*x2-6.*y2+1+0.5.*(x1-x2), 6.*x2-7.*y2+1+dy.*(y1-y2)];
v = [x1,y1,x2,y2];
R0 = jacobian(f,v);
d0 = eig(R0);
dmax = [max(d0)]
M(i,2) = dmax;
i = i+1;
end
plot(M(:,1),M(:,2))
What should I do if I want to define a continuous range and improve the working speed of the script?
Thanks in advance.

回答 (1 件)

Chidvi Modala
Chidvi Modala 2020 年 1 月 3 日
If you can provide the time it is taking to plot the graph by using tic and toc, it will be helpful. Because it is taking just 3s for me to run the entire script.

カテゴリ

Help Center および File ExchangeDirected Graphs についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by