How do I plot points coming from a for loop without using vectors?
1 view (last 30 days)
Salvatore Manfredi D'Angelo on 22 Jul 2021
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.
Konrad on 22 Jul 2021
values on the x-axis are not equally spaced because on every interation you increase L by i, which itself is increased by 1 on every interation:
1st interation: L = 0+0 = 0
2nd L = 0+1 = 1
3rd L = 1+2 = 3
4th L = 3+3 = 6
but you can just use i as your x-parameter for the plot function:
> "is there a way to plot points coming from a for loop as they get out, without using vectors?"
you allready do that using hold on