Question

Matlab fprintf help

This is the question:

I have already done part a, I need help with part b.

This is my current code:

% array of Pounds to convert to Kilograms

weight_pound = [50.543 65.676 75.343 80.937]

% for Loop that calls from the array weight_pounds

for index=1:4

%Convert weight from Pounds to Kilograms

    weight_kg = weight_pound*0.453592

%Print out the conversion

% ‘%5.2f’ for 2 decimals for Kilograms

% ’%5.0f’ for no decimals in pounds

    fprintf(‘%5.2f kg = %5.0f lb\n',weight_pound(index),weight_kg);

% end loop

end

Matlab isnt accepting my code. It says its full of errors. Help!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I found 2 erros in the code you wrote

  • 1 kg = 2.20462 lbs
  • You were trying to do weight_pound*2.20462 but it should be weight_pound(index)*2.20462 because you need one element at a time
weight_pound = [50.543 65.676 75.343 80.937];
for index=1:4
weight_kg = weight_pound(index)*2.20462;
fprintf('%5.1f kg = %5.0f lb\n',weight_pound(index),weight_kg);
end

Output

50.5 kg = 111 lb
65.7 kg = 145 lb
75.3 kg = 166 lb
80.9 kg = 178 lb

Add a comment
Know the answer?
Add Answer to:
Matlab fprintf help This is the question: I have already done part a, I need help...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • NEED help. Have to be done by hand and MATLAB. please help 2.) After the conversion...

    NEED help. Have to be done by hand and MATLAB. please help 2.) After the conversion above nearly reaches equilibrium, the mixture is pumped to a distillation column where form C is desired. The feed stream is 34% A, 24% B and 42% C by weight. The bottom exit stream is 10% A 20% B and 70% C, while the top exit stream only contains 20% C by weight and flows at 20 kg/hr. (a - 2 points) Arrange this...

  • Hi, I need some help with the following question. I need the answer in Python please....

    Hi, I need some help with the following question. I need the answer in Python please. 10.23 LAB: Warm up: People's weights (Lists) (1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Output the list. (2 pts) Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3] (2) Output the average of the list's elements...

  • ZYBOOKS LAB: 10.23.1 Hello, I'm trying to solve this problem with creating a program code in...

    ZYBOOKS LAB: 10.23.1 Hello, I'm trying to solve this problem with creating a program code in Python about People's Weights. Here is the question: 10.23 LAB: Warm up: People's weights (Lists) (1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Output the list. (2 pts) Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3]...

  • MATLAB help! I have some MATLAB Assignment to do, the proffesor requires all the small parts...

    MATLAB help! I have some MATLAB Assignment to do, the proffesor requires all the small parts in order to get full credit. Help me out, thank you f LAB SECTION NAME HW6P3 (30 points) following are infinite series representations of the function, un pra i a script file HW6P3 that determines the value of the function from the sum of the series for a given value of x. The program (1 pt) must prompt the user to enter a value...

  • Hello, can someone please help me correct this code? I greatly appreciate it. 7.16 Ch 7...

    Hello, can someone please help me correct this code? I greatly appreciate it. 7.16 Ch 7 Warm up: People's weights (Lists) (Python 3) (1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Output the list. (2 pts) Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3] (2) Output the average of the list's elements...

  • help me with the problem below my percent body fat is 95% I weight 160 pounds...

    help me with the problem below my percent body fat is 95% I weight 160 pounds my height is 5"2 There are several different ways to compute an ideal body weight. Method A of this laboratory enables you to compute and record your ideal body weight using skinfold measurements. (In Chapter 6 we discussed body fat percentage estimated from skinfold measurements.) Method B enables you to calculate and record your ideal body weight using the body mass index (BMI) procedure...

  • Lanuage C++ (Beginner level) Please...I need help with this assignment If I still have question, can...

    Lanuage C++ (Beginner level) Please...I need help with this assignment If I still have question, can i contact you? -------------------------- Program 1 - WRITE ALL THE CODE in ONE FILE...   MyArrayPtrArith1.cpp Step 1 - Define the class Write a class, myArrayClass, that creates an integer array. * Add an 'arraySize' variable, initialize to zero ( default constructor function ) * Create int * ptrArray ( default constructor set to NULL ) * Add a default constructor ( see above for...

  • Hi please help with c++ programming. This is my code. there's a syntax error. PLEASE FIX...

    Hi please help with c++ programming. This is my code. there's a syntax error. PLEASE FIX MY CODE instead of re-designing the program. Thanks /*    Description of problem: Introduction to Friends functions. Create objects in the stack (not on the heap) 3.1: Add a friend function, kilotopound, which will convert kilograms to pounds. 3.2: Add a copy constructor utilizing Lab 3.1 code. Copy the fist object using a copy constructor. Output the contents of both objects. */ #include <iostream>...

  • Matlab help *****CONSTANT***** NUM_MONTHS = 12; FIRST_YEAR = 2013; LAST_YEAR = 2016; %*****...

    matlab help *****CONSTANT***** NUM_MONTHS = 12; FIRST_YEAR = 2013; LAST_YEAR = 2016; %*****INPUT***** months = 1:NUM_MONTHS; years = FIRST_YEAR:LAST_YEAR; % read data file lake_powell = load( 'lake_powell.txt' ); % OR load lake_powell.txt % print with title and year column headings. fprintf(' Lake Powell Water Levels (in feet)\n') fprintf('%8d ', years) fprintf('\n') % print contents of lake_powell for month = 1:NUM_MONTHS fprintf('%9.2f', lake_powell(month,:)) fprintf('\n') end % PART B ========================================================== fprintf('\nPART B: Determine average elevation of water level for each year and...

  • This is a matlab HW that I need the code for, if someone could help me figure this out it would b...

    This is a matlab HW that I need the code for, if someone could help me figure this out it would be appreciated. The value of t can be estimated from the following equation: in your script file, estimate the value of π for any number of terms. You must ask the user for the desired number of terms and calculate the absolute error/difference between your calculation and the built-in MATLAB value ofpi. Display your results with the following message...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT