Question

Use MATLAB in all problems and be sure to use suitable MATLAB variable names. a) Write...

Use MATLAB in all problems and be sure to use suitable MATLAB variable names.

a) Write a single line command to create an array sentenceB which stores the contents of array sentenceA in reverse. Hint: end:-1:1

b) Initialize a string array named sentenceA containing: ‘She ZZZZZ XXXYYYYYY by the XXXshore,’ Write a script using a for-loop (without using the MATLAB command strrep()) to replace according to the below: Replace XXX with ‘Sea’ Replace ZZZZZ ‘Sells’ Replace YYYYYY with ‘SHELLS’

c) Repeat part b) using strep()

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

Question A:

sentenceA = [1 2 3 4 5]

sentenceB = sentenceA(end:-1:1)

Question B:

sentenceA = 'She ZZZZZ XXXYYYYYY by the XXXshore'

s1 = 'Sea';

s2 = 'Sells';

s3 = 'SHELLS';

for i = 1:3

sentenceA(i+10) = s1(i);

sentenceA(i+27) = s1(i);

end

for i = 1:5

sentenceA(i+4) = s2(i);

end

for i = 1:6

sentenceA(i+13) = s3(i);

end

sentenceA

Question C:

sentenceA = 'She ZZZZZ XXXYYYYYY by the XXXshore'

sentenceA = strrep(sentenceA,'XXX',s1)

sentenceA = strrep(sentenceA,'ZZZZZ',s2)

sentenceA = strrep(sentenceA,'YYYYYY',s3)

Add a comment
Know the answer?
Add Answer to:
Use MATLAB in all problems and be sure to use suitable MATLAB variable names. a) Write...
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
  • Solving digital system problems using MATLAB Write a MATLAB script CTask2p3.m to: a) Generate the...

    Solving digital system problems using MATLAB Write a MATLAB script CTask2p3.m to: a) Generate the truth table for the following Boolean expressions and display it in the MATLAB command window (Use logical functions: and, not, or)

  • Problem 5 (10 points): MATLAB script-5 Write a script that will accept a single variable named...

    Problem 5 (10 points): MATLAB script-5 Write a script that will accept a single variable named S. The script should replace S with the square of S and repeat this process until S is either greater than 1015 or less than 1015. The script should return a value Q containing the number of times S was squared during the process. If S equals 1, the function should display a warning message and retun the value of Inf for Q Examples:...

  • 1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector...

    1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector containing the values of the integral (A) for n= 1,2,3,..., n. The function must use the relation (B) and the value of y(1). Your function must preallocate the array that it returns. Use for loop when writing your code. b) Write MATLAB script that uses your function to calculate the values of the integral (A) using the recurrence relation (B), y(n) for n=1,2,... 19...

  • Chapter 6 Matlab Assignment: Assume x is a row vector containing 100 elements. Write a counter-controlled...

    Chapter 6 Matlab Assignment: Assume x is a row vector containing 100 elements. Write a counter-controlled loop using a "for" command and an "if" command that examines one element of x each time through the loop. If that element is greater than 10, replace it with a random integer between 1 and 20. Chapter 7: Explain the use of functions in computational programs like the ones you wrote

  • ArraysAndFiles.java and PartiallyFilledArray.java. They are shells that do not do anything. You will be adding code...

    ArraysAndFiles.java and PartiallyFilledArray.java. They are shells that do not do anything. You will be adding code after the comments in the main method and using the javadoc documentation to implement the other methods. Task 1: Send array data to the screen In ArraysAndFiles.java, create a new method printOnScreen and compile it. In the main method of ArraysAndFiles.java, add the code to declare and initialize the array of Strings and call printOnScreen to print the array on the screen. Task 2:...

  • The Following are requirements for a Matlab Program. Open the specification sheet file for the SolarWorld...

    The Following are requirements for a Matlab Program. Open the specification sheet file for the SolarWorld brand solar electric module Scroll to the top of the 2^nd page and note the three models and associated data Write a script (*.m) file and load the following data into arrays: Model (use the char function for string elements) Voc Vmpp isc Impp Efficiency Use a for/end loop to load the data into a structure array called SolarWorld Each field should be named...

  • can u please on matlab, i have the solution on paper. [30pts] Write a robust, efficient...

    can u please on matlab, i have the solution on paper. [30pts] Write a robust, efficient MATLAB script to find the eigenvalues and eigenvectors of a 2 x2 matrix input by the user. You should test out your script using the following matrices. 1::)-::) 3 2 3 1 B. 1 2 C 2 3 A- D- 4 1 2 4 4 8 -3 8 You may not use any special MATLAB tools. Instead, work symbolically and derive general expressions for...

  • write a java program that does the following Part one Use a For loop to compute...

    write a java program that does the following Part one Use a For loop to compute the sum of all the odd numbers from 1 through 99. Your result should be labeled, and the value should be 2500. Print your name 7 times using a While loop. String dogNames[ ] = {"Sam","Buster","Fido","Patches","Gromit","Flicka"}; Using the array defined here, print the values of the array vertically and horizontally using one For-Each loop. Reverse the logic (Nested loops: Indent text) so that the...

  • 3. Write Java methods to accomplish each of the following Write a method named simpleAry which...

    3. Write Java methods to accomplish each of the following Write a method named simpleAry which accepts and return nothing. It creates an array that can hold ten integers. Fill up each slot of the array with the number 113. Then, display the contents of the array on the screen. You must use a loop to put the values in the array and also to display them. Write a method named sury which accepts an array of type double with...

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