MATLAB: How can i use for loop to solve the below problem

matlab coderMATLAB Online Server

Add an if statement to the for loop body. If speed(c) is less than or equal to 0, create a loglog plot of s against lambda using a dashed line ().
After the if statement, add the command hold on so that only one plot is created.
the below didnt work for me:
if speed(c) <= 0
loglog(lambda,s,"--")
end
hold on
end

Best Answer

You have used an extra end. Delete the end in the last line. I think you must use hold on before your for loop and place the if inside the for loop.