DeGracia_Miguel_19481379_Lab5

# DeGracia_Miguel_19481379_Lab5 - %matrix form as well...

This preview shows pages 1–2. Sign up to view the full content.

%% Miguel De Gracia. 19481379. Lab Assignment 5. Section 22 % %% Problem 1a % x=2; y=3; x x > y x < y x >= y x <= y x == y x ~= y %The problem returns a 1 if the statement is true, and a 0 if the statement %is false. % %% Problem 1b % y = [1 3; 5 2]; y x > y x < y x >= y x <= y x == y x ~= y all(y==x) any(y==x) find(y<=x) %In this case since y is now a matrix, it compares x to every element of y %and performs the same task as the previous problem. For all or any it does %so by comparing it according to each column.Find returns the indeces in %which the logical statement is true. % %% Problem 1c % x = [2 4; 5 1]; x x > y x < y x >= y x <= y x == y x ~= y all(y==x) any(y==x) find(y<=x) %Since both x and y are now matrices, it compares the elements and %evaluates the logical command at that element, returning an answer in

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %matrix form as well. % %% Problem 1d % a=1; b=0; c=1; a a | b a & b a | c & b (a | c) & b a & (c | b) ~a & c ~(a | b | c) %Evaluates the logical operators when | means or, & and. Compares the %statement and evaluates if the values are equal. % %% Problem 1e % 5 > 2+4|~2+5==5 %Evaluates the furthermost expression 5==5 which is true so it becomes a %one, then 2+1 is 3, then now the expression looks like 6|~3, which will %return a 1, and at the end 5>1 is true so the answer is now 1. % %% Problem 2 % f1(-8) f1(-3) f1(4) f1(17) f type f1 t %% Problem 3 % type poly_adder t %% Problem 3a % poly_adder([1 2 3],[2 1 3]) p %% Problem 3b % poly_adder([1 2 3 4],[1 0 4]) p %% Problem 3c % poly_adder([1 5],[3 2 1 5]) p %% Problem 4 %...
View Full Document

## This note was uploaded on 02/18/2010 for the course ENGINEERIN 7 taught by Professor Patzek during the Spring '08 term at Berkeley.

### Page1 / 2

DeGracia_Miguel_19481379_Lab5 - %matrix form as well...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online
The provided text is a MATLAB script or lab assignment that contains several problems and their solutions, primarily focusing on logical operations and comparisons between variables and matrices. The problems are structured to demonstrate the use of logical operators and functions in MATLAB.
no_question

the text does not contain any explicit mathematical questions that require an answer. instead, it provides a series of matlab commands and comments explaining what each command does. the commands are executed to demonstrate the behavior of logical operations and comparisons in matlab.
Given a text passage, determine:
    1. If it contains a mathematical question (including word problems or calculations)
    2. If an answer to that mathematical question is provided in the text

First, describe the content structure you found in 1-2 sentences.

Then provide your analysis in the following format:
TYPE: <one of the following values>
- NO_QUESTION
- SINGLE_QUESTION
- SINGLE_QUESTION_WITH_ANSWER
- MULTIPLE_QUESTIONS
- MULTIPLE_QUESTIONS_WITH_ANSWERS
system
DeGracia_Miguel_19481379_Lab5

# DeGracia_Miguel_19481379_Lab5 - %matrix form as well...

This preview shows pages 1–2. Sign up to view the full content.

%% Miguel De Gracia. 19481379. Lab Assignment 5. Section 22 % %% Problem 1a % x=2; y=3; x x > y x < y x >= y x <= y x == y x ~= y %The problem returns a 1 if the statement is true, and a 0 if the statement %is false. % %% Problem 1b % y = [1 3; 5 2]; y x > y x < y x >= y x <= y x == y x ~= y all(y==x) any(y==x) find(y<=x) %In this case since y is now a matrix, it compares x to every element of y %and performs the same task as the previous problem. For all or any it does %so by comparing it according to each column.Find returns the indeces in %which the logical statement is true. % %% Problem 1c % x = [2 4; 5 1]; x x > y x < y x >= y x <= y x == y x ~= y all(y==x) any(y==x) find(y<=x) %Since both x and y are now matrices, it compares the elements and %evaluates the logical command at that element, returning an answer in

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %matrix form as well. % %% Problem 1d % a=1; b=0; c=1; a a | b a & b a | c & b (a | c) & b a & (c | b) ~a & c ~(a | b | c) %Evaluates the logical operators when | means or, & and. Compares the %statement and evaluates if the values are equal. % %% Problem 1e % 5 > 2+4|~2+5==5 %Evaluates the furthermost expression 5==5 which is true so it becomes a %one, then 2+1 is 3, then now the expression looks like 6|~3, which will %return a 1, and at the end 5>1 is true so the answer is now 1. % %% Problem 2 % f1(-8) f1(-3) f1(4) f1(17) f type f1 t %% Problem 3 % type poly_adder t %% Problem 3a % poly_adder([1 2 3],[2 1 3]) p %% Problem 3b % poly_adder([1 2 3 4],[1 0 4]) p %% Problem 3c % poly_adder([1 5],[3 2 1 5]) p %% Problem 4 %...
View Full Document

## This note was uploaded on 02/18/2010 for the course ENGINEERIN 7 taught by Professor Patzek during the Spring '08 term at Berkeley.

### Page1 / 2

DeGracia_Miguel_19481379_Lab5 - %matrix form as well...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online
user
The provided text is a MATLAB script or lab assignment that contains several problems and their solutions, primarily focusing on logical operations and comparisons between variables and matrices. The problems are structured to demonstrate the use of logical operators and functions in MATLAB.

TYPE: NO_QUESTION

The text does not contain any explicit mathematical questions that require an answer. Instead, it provides a series of MATLAB commands and comments explaining what each command does. The commands are executed to demonstrate the behavior of logical operations and comparisons in MATLAB.