Solving MATLAB Duplication Error with For Loop

  • Context: MATLAB 
  • Thread starter Thread starter Superposed_Cat
  • Start date Start date
  • Tags Tags
    Error Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
6 replies · 3K views
Superposed_Cat
Messages
388
Reaction score
5
Hi, I'm totally new to MATLAB and tried this for loop

Code:
for K = 1:10
  disp(abs(tan(K)))
end

it displays
Code:
1.5574
 2.1850
 0.14255
 1.1578
 3.3805
 0.29101
 0.87145
 6.7997
 0.45232
 0.64836

 1.5574
 2.1850
 0.14255
 1.1578
 3.3805
 0.29101
 0.87145
 6.7997
 0.45232
 0.64836

Why did it display this twice?
Thanks for any help.
 
Physics news on Phys.org
Thanks, When I did it again it worked without changing anything but it happened again and duplicated a graph.
 
lol, the button only allows you to press it once before changing to a animated non-clickable gear.
 
try "clc" before the script
 
whats that do?