MATLAB: How to set up script using for loop

forhomework

write a MATLAB script that uses a FOR loop to simulate a leaky faucet. The leaky faucet is dripping at a rate of one 0.1 milliliters drop every 3 seconds. Write a MATLAB script that plots the amount of water lost over 1 hour.

Best Answer

  • A for loop is one of the most basic constructs in MATLAB. I'm sure it must be covered in the "Getting Started" documentation. Here's a start
    amountLeaked(1) = 0;
    for t = startTime : timeIncrement : stopTime
    % Code.....
    amountLeaked(t) = .......
    end
    plot(t, amountLeaked,.......
    grid on;
  • Related Question