CS 1371 Lecture Notes - Lecture 4: Logical Connective, C String Handling, Matlab

99 views4 pages

Document Summary

Logical operators: , <=, >=, ==, ~= (do the same as the math operators) out1 = 14 > 7; => out1 = true out2 = 6 ~= 6; More logical operators: & (and), | (or) out3 = true & true & false; => out3 = false out4 = true | false | true; Logical functions: all(), any() out5 = all([true, true, true, false]); => out5 = false all() is the same as a bunch of & signs out6 = any([false, true, false, false]); => out6 = true any() is the same as a bunch of | signs. Indexing lower case letters out of a string lowercase = str(str>="a" & str<="z"); Index out all nonzero values nonzero = vec(vec~=0); Reverse a vector (without fliplr) flipped = vec(end:-1:1); Does a string contain a number? numbers = str(str>="0" & str<="9"); out = length(numbers) > 0; Or numbers = str(str>="0" & str<="9"); out = isempty(numbers);

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

Related Questions