# matlab | 代写oop | 代写assignment | lab – Homework # 1 Assignment

### Homework # 1 Assignment

matlab | 代写oop | 代写assignment | lab – 这是一个关于matlab的题目, 主要考察了关于matlab的内容,是一个比较经典的题目, 是比较有代表性的matlab/oop等代写方向, 这是值得参考的lab代写的题目

#### Problem 1 ( 50 points)

###### a. Read the csv file Cars Data.csv into an R dataframe variable cars (5 points)

## Insert R code here (^) cars<-read.csv( # ‘/users/xuanyuzhou/desktop/ise-535/Cars Data .csv’)

###### b. Check the class and dimensions of cars. (5 points)

## Insert R code here (^) class(cars)

dim(cars)

## [1] 428 15

#

###### c. Display the second and fourth columns of the first 5 items in the dataframe (5 points)

## Insert R code here (^) cars[ 1 : 5 ,c( 2 , 4 )]

(^) (^) M M ooddeell O O rriiggiinn

###### d. Display the names of the columns in cars. (5 points)

## Insert R code here (^) colnames(cars)

## [9] "Invoice" "Length..IN." "MPG..City." "MPG..Highway." ## [13] "MSRP" "Weight..LBS." "Wheelbase..IN."

#

###### e. Display the average number of cylinders in the cars dataframe (10 points)

## Insert R code here (^) mean(cars\$Cylinders, na.rm = TRUE)

## [1] 5.

#

###### f. Add a new column to your dataframe called wt_len_ratio that is the weight (in pounds) divided by thewheelbase length (in inches) (10 points)

## Insert R code here (^) # cars\$wt_len_ratio <- cars\$Weight..LBS./cars\$Wheelbase..IN.

###### g. Display the Make and Model of the car with the highest horsepower (10 points)

## Insert R code here (^) sorted_cars <- cars[order(cars\$Horsepower, decreasing = print(sorted_cars\$Make[ 1 ]) T),]

## [1] "Dodge"

print(sorted_cars\$Model[ 1 ])

## [1] "Viper SRT-10 convertible 2dr"

#

#### Problem 2 ( 50 points)

###### Test the function with a height of 72 and a weight of 190 lbs. (15 points)

## Insert R code here (^) calculate_bmi <- height_m <- height_in* function 0.035(height_in, weight_po){ weight_kg <- weight_po* return (weight_kg/(height_m*height_m))0. (^) }BMI <- calculate_bmi( (^72) , 190 ) BMI

## [1] 22.

#

##### inches 0. 035 = m pounds 0. 753592 = kg
###### Height: 68 / weight 160 lbsHeight 72 / weight 190 lbs

## Insert R code here (^) determine_weight_category <- BMI <- calculate_bmi(height_in, weight_po) function (height_in, weight_po){ if (BMI < return (18.5"Underweight"){ (^) ) } elsereturn if (BMI < ("Normal weight" 25 ){ (^) ) } elsereturn if (BMI < ("Overweight" 30 ){ (^) ) } elsereturn { (^) ("Obese") }} (^) determine_weight_category( 60 , 160 )

## [1] "Overweight"

determine_weight_category( 68 , 160 )

## [1] "Normal weight"

determine_weight_category( 72 , 190 )

## [1] "Normal weight"

#

###### for a 180-Pound Individual and label the X and Y axes. (15 points)

## Insert R code here (^) heights <- seq(BMIs <- NULL 60 , 84 , 1 ) for BMIs <- c(BMIs, calculate_bmi(height, (height in heights){ (^180) )) }plot(heights, BMIs, main = (^) "BMI at Various Heights for a 180-Pound Individual")

####### #

###### d. Repeat the question of part c without using a for-loop by replacing the loop with a single R statement. (5points)

## Insert R code here (^) BMIs <- calculate_bmi(heights, plot(heights, BMIs, main = "BMI at Various Heights for a 180-Pound Individual" 180 ) (^) )

####### #