MATLAB: My problem is, the display of the plot were dots. how will i able to display it with a curve line. the main code shoud be inside of the for loop.

plot problems

for x=0.3:0.01:0.5
hold on

Best Answer

  • If I were making this plot, I would do as Jose has indicated. However, I want to show you a more proper way to get it done with a FOR loop because some things are not so easily vectorized as this.
    x = 0.3:0.01:0.5; % Define this first.
    y = zeros(size(x)); % reserve memory for y.
    for ii = 1:length(x)
    y(ii)=15e-9*exp(x(ii)/25e-3)-1; % Fill y, one at a time.