In order to plot all the data points and curves plotted on the same plot using a ‘for’ loop, the code provided in the question above can be modified to include the ‘for’ loop as follows-
% Loop over each column of data
for i = 1:size(Concentration, 2)
% Extract current column data
xdata = Concentration(:, i);
ydata = aveMortality(:, i);
% Perform curve fitting
x = fminsearch(@(x) norm(ydata - fun(x, xdata)), x0, opts);
% Plot the data points
plot(xdata, ydata, 'o', 'MarkerSize', 8, 'DisplayName', sprintf('Data %d', i));
% Plot the fitted curve
x_fit = linspace(min(xdata), max(xdata), 100); % Generate x values for fitting
y_fit = fun(x, x_fit);
plot(x_fit, y_fit, '-', 'LineWidth', 2, 'DisplayName', sprintf('Fit %d', i));
end
For more information on the usage of ‘for’ loop, please refer to the documentation link below-
I have also attached the output plot obtained after using the above loop below, for your reference.

I hope this solves the purpose.
