Inside the body of the for loop, at any one time, T will be a scalar value. The first iteration it would be the scalar value -10, the second time it would be the scalar value -5, and so on.
F = integral(fun,lamda_1,lamda_2)./(sigma.*(T+273)^4)
The result of integral() is always a scalar, unless you have passed in the option 'ArrayValued', true
so there you are plot() with a scalar T and scalar F. But by default, plot() is only for drawing lines, and in order to draw a line, plot needs to be be passed something that includes at least two adjacent finite values. With scalar T and scalar F, there is only the one point, when it needs at least two points to join to create a line.
plot() does not "remember" the previous points that have already been drawn to automatically join them together -- that would typically be the wrong thing to do.
There are several different things you can do:
- you can plot(T, F, '*') which will not create any lines, but will at least put a * marker at every point
- you can keep a record of each T and F value, storing the values inside vectors inside the loop, and then plot afterwards with no plot inside the loop. I recommend that you read https://www.mathworks.com/matlabcentral/answers/504285-for-loop-for-non-consecutive-values-in-an-array#answer_414399
- you can keep track of the handle of the "chart line object" (line()) that plot() outputs, and then each iteration of the loop, pull out the XData and YData properties of that line() object, and add the new T and F point to the ends of those lists, and set those as the new values for the XData and YData properties. The line() object is the internal representation of which points are to be drawn, so updating the XData and YData properties would cause it to extend the existing line
- you can use animatedline() and addpoints() to hide the details of the kind of XData / YData tracking that I mentioned above.
Except for very long loops where you want to see plotting results before the function finishes, I recommend taking the approach of recording the values and plotting afterwards.