Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Strings in Matlab are just arrays of characters. Like other Matlab arrays, they can be concatenated (merged together) using the square bracket notation. Play around

Strings in Matlab are just arrays of characters. Like other Matlab arrays, they can be concatenated (merged together) using the square bracket notation. Play around with string concatenation until you understand how it works.

Part A. Declare a variable with your name as its string value. Declare a second variable with the string " understands string concatenation!" in it. Declare a third variable that concatenates the first variable and second variable together. Print the third variable using fprintf and end the line with a newline.

Part B: Declare a string variable with the value 'a'. What happens if you add the numerical value 1 to that variable? What happens if you concatenate your variable with the value of your variable + 1? Assign that sum to a variable and uses fprintf to print it as an integer. Then print it as a string. Understand what happened there. Use a loop and concatenation to fill your variable with the letters of the alphabet. The special array index value end that we discussed in lecture may be helpful here. Use fprintf to print your alphabet string.

Part C: Use Matlab's help feature to look up the repmat function. Understand how repmat can be used to create an array consisting of the input array duplicated as either rows or columns (or both). Use that function and your result from part 2b to create and print a string that has the alphabet in it 3 times in one row, separated by spaces.

Part D: Look at the format specifier you used to print a line of numbers for the first problem. Use repmat and string concatenation to create a format string that will print the following row array with that 10.4 format and a newline at the end.

z = [81.47, 90.57, 12.69, 91.33, 63.23, 9.75, 27.84, 54.68, 95.75, 96.48] Use that format string to print z. Could you have created your format string such that it automatically adjusted for a z with a different length?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

(c) Illustrate (a) and (b) with the function f (x) = x2. lim lim im

Answered: 1 week ago

Question

8. Explain the relationship between communication and context.

Answered: 1 week ago

Question

What does stickiest refer to in regard to social media

Answered: 1 week ago