Search Results XY a 404-File or directory no × /MAT LAB/CS%201 371 /Hw03-Drillpr
ID: 3879279 • Letter: S
Question
Search Results XY a 404-File or directory no × /MAT LAB/CS%201 371 /Hw03-Drillproblems.pdf Function Name: sweaterWeather Inputs: 1. (char) A 1xN vector of characters 2. (char) A second 1xN vector of characters Outputs: 1. (char) A new 1x(2 N) woven vector Background Upon discovering the forecast for chilly weather this morning, you don your favorite striped sweater! You notice the pattern of alternating threads woven into your sweater, and (being a MATLAB enthusiast) you decide to write a function that can weave vectors together in a pattern much like that of the threads in your own dashing cardigan. Function Description: Weave two vectors together, alternating between one letter of the first vector and one letter of the second vector, such that the output vector contains the characters of the first vector at its odd indices and of the second vector at its even indices. Example: the vector HLovelrle Given the character vectors mean and 'soetd , your function should utput Notes: . You are guaranteed that the input vectors will be of the same length (N 2 1) . Be sure that your output is of type char Hints: Think about how you can use the colon operator to create an index vectorExplanation / Answer
a='Ilv ALB';
b=' oeMTA!';
for i=1:length(a)
fprintf('%c%c',a(i),b(i))
end
fprintf(' ');
This is with static input in the program script. If you want a dynamic one then you can put a = input(prompt,'s') and b = input(prompt,'s'). Also you would need to check the size of the 2 elements by yourself by if(length(a)==length(b)) and then write the code.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.