How to define a continuous range?
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!