Load the data into a vector and compute this average using a while loop + Using tic() and toc()

Hello, my name is Paul. I'm a beginner user in MATLAB. One of my courses assign me a problem I should use a while loop (with a text file), and tic() and toc(). Below is what I want to create.
Problem Statement
You are an electrical engineer working with renewable energy. The file ClassSDPprep_watss.txt has the maximum power in Watts required in a house for each day for the month of March. You want to compute the average power requirement for the month of March. You will need to load the data into a vector and compute this average using a while loop. Using tic() and toc() determine how long the program took to run and print the results to the screen.
I attach the text file that is needed to be calculated using a while loop as well as my attempt typing codes.
Appreciate your time and understanding.

回答(1 个)

Undefined function 'Length' for input arguments of type 'double'.
Error in Problem_3_SDP_code (line 14)
while Period < Length(Power)
MATLAB is case sensitive. Length() is considered to be different than length()

类别

帮助中心File Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!