Question

Please write a MATLAB code for this

4. Create a function called changearray(A) that would add 20 to all non-positive elements of an array A and take the natural

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

function z= changearray(A)

s = size(A);

nr = s(1);

nc = s(2);

z = zeros(nr,nc);

for i= 1:nr

for j= 1:nc

z(i)(j) = log(A(i)(j));

if (A(i)(j) < 0)

z(i)(j) = A(i)(j)+20;

end

end

end

end

Add a comment
Know the answer?
Add Answer to:
Please write a MATLAB code for this 4. Create a function called changearray(A) that would add...
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
  • Matlab. Please add comments. Thank you in advance. 15. Write a code that can read in...

    Matlab. Please add comments. Thank you in advance. 15. Write a code that can read in a string and replaces all vowels with x's 16. Write a function that reads in a D array of any length, u, and swaps elements of the array in the following way. The first and last element are swapped. The second and second to last element are swapped. The third and third to last element are swapped, and so on until all the elements...

  • write a Matlab program ( solve the three questions). please use array and create your own...

    write a Matlab program ( solve the three questions). please use array and create your own function to check primality Question 1 : [10 points) Write a MATLAB program that will store all the first 1000 prime numbers in an array variable named arr_of_primes. Please note that a prime number is a positive integer that is bigger than or equal to 2 which is divisible only by 1 and itself. Examples of the first 8 primes are: 2, 3, 5,...

  • Please write in MATLAB code: 1. Write a function called myMin4 that will take in four...

    Please write in MATLAB code: 1. Write a function called myMin4 that will take in four numbers and returns the minimum value. You may NOT use the built-in min() function. Run the function for the following: myMin4(4, 8, 12, 15) myMin4(18, 9, 1, 6) myMin4(8, -2, 2, 10) 2.   Write a function called classAverage that takes in an array of numbers and returns the letter grade of the class average. The grade ranges are as follow: Average >90 = A...

  • ** Please provide a code in MATLAB ** 1. Write a function called taxcalculator that reads...

    ** Please provide a code in MATLAB ** 1. Write a function called taxcalculator that reads an amount in dollars, adds tax based on the table below and return the total with tax using elseif statement. 2. Write a function called printstars that reads the number of rows and returns a triangle of stars similar to the one below:       *      **     ***    ****   *****  ****** ******* ********

  • how would i code this in MATLAB 4. The goal in this problem is to add...

    how would i code this in MATLAB 4. The goal in this problem is to add two 20 digit integers Sounds easy right? Try this: 1 11111111 1111; printf("%30.08 ) The issue is that the computer cannot store a 20 digit integer exactly. You need to find a ww around this but use non-standard data types (you can't just use a big float) Create a function whose input is two 20 digit integers. Return the sum of the integers. In...

  • Matlab Write a function called matrixsum that takes any matrix to calculate and return the sum...

    Matlab Write a function called matrixsum that takes any matrix to calculate and return the sum of all matrix elements (this function must not use any array operations. It must instead use a for-loop.)

  • l Question 2 -JS and Python a) Write JavaScript code to create a function called "sortstingsDesc"...

    l Question 2 -JS and Python a) Write JavaScript code to create a function called "sortstingsDesc" that will sort an array of string suppiied as a parameter in descending order. (4) Write Python code to create a function called "addToFront" that will accept two parameters the list of information and the value to be added and place the value to the beginning of the list. [4) b)

  • A=[-6,8,2;1,-3,20;15,-10,5]; Write a program that computes the array B by computing the natural logarithm of all...

    A=[-6,8,2;1,-3,20;15,-10,5]; Write a program that computes the array B by computing the natural logarithm of all the elements of A whose value is greater than or equal to 1. Otherwise add 30 to each element that is less than 1. Do this in two way. A) By using a for loop with conditional statements B)By using a logical array as a mask MATLAB CODE

  • Matlab code 4) Write a function leadzero(v) which takes as input a vector v and as...

    Matlab code 4) Write a function leadzero(v) which takes as input a vector v and as output, c, returns the number of zeros at the beginning of v (number of zero elements before any non-zero element). For example, for input (-5, 5, 11] the output would be 0. If the input is [0, 0, 3, 0, 0, 0], the output would be 2. If the input is [0, 0, 0, 0, 7, 4) the output would be 4. 5) Write...

  • What would the function look like in MATLAB? Write a function called mysort that takes a...

    What would the function look like in MATLAB? Write a function called mysort that takes a 3-element vector as its sole arguments. It uses if statements, possibly nested, to return a 3-element vector with its elements in non-decreasing order, i.e., the first element in the returned vector equals the smallest element of the input vector and the last element equals the largest element in the input vector. NOTE: Your function should not use any built-in functions, e.g., sort, min, max,...

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