How do I plot points coming from a for loop without using vectors?
Afficher commentaires plus anciens
Hi, I am new to Matlab so excuse my ignorance. I am trying to make a code that evaluates a definite integral from 0 to infinity for different values of two parameters, which I called v,L in the script below. Then I want to plot these definite integrals versus values of, say, L, which increases by one in each cycle. Why aren't values of L on the horizontal axis equally spaced as they should be? Is there something wrong with the plot function? If so, is there a way to plot points coming from a for loop as they get out, without using vectors? Thanks in advance.

syms x;
double L;
double v;
f=L*exp(-v*x^2);
L=0;
v=1;
for i=0:50
L=L+i;
k=int(f,x,0,inf);
plot(L,k,'o');
hold on
end
hold off
3 commentaires
Stephen23
le 22 Juil 2021
Note that
double L;
is equivalent to
double('L');
and is unlikely to be of much use to you.
Salvatore Manfredi D'Angelo
le 22 Juil 2021
Konrad
le 22 Juil 2021
I think what Stephen refers to is that
double L; % = double('L')
doesn't declare a variable (as in other languages), but type-casts the character 'L' to type double, which is simply the number 76.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Conversion Between Symbolic and Numeric dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
