CS 1371 Lecture Notes - Lecture 5: For Loop, Matlab

54 views4 pages

Document Summary

While loops while expression, statements, end evaluates an expression, and repeats the execution of a group of statements in a loop while the expression is true. An expression is true when its result is nonempty and contains only nonzero elements (logical or real numeric). end homework = "cs1371, biol1510, math1502"; assignmentcount = 0; while ~isempty(homework) [class, homework] = strtok(homework, ", "); assignmentcount = assignmentcount + 1; fprintf("\ni have finished d homework. Or, more realistically homework = "cs1371"; homeworkdone = false; while ~homeworkdone fprintf("\nstill working on s",homework); end. For loops repeat a specified amount of time. Now that you did all your homework, you want to see how you did homework = "cs1371, biol1510, math1502"; grade = [60, 92, 44]; curve = [18, 0, 28]; for i = 1:length(grade) [class, homework] = strtok(homework, ", "); score = grade(i) + curve(i); fprintf("s homework grade: d\n",class, score); end. Finds the sum along the major diagonal thesum = 0;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents