Hi! i need help with this program with arrays

1 visualizzazione (ultimi 30 giorni)
Anthony Fuentes
Anthony Fuentes il 27 Ott 2016
Modificato: Jan il 28 Ott 2016
Hi! I need help with the following ! I have no idea to realize it. Can you help please? Please in everything that you contribute, I will be very thankful! The instructions: (A) Write a function that receives an array of any size and return the average of all numbers in the matrix. Schedule your function using loops, DO NOT use the predefined functions allowed Matlab: sum, cumSum, mean. (B) Write a function that receives an array of any size and maximum and minimum return of all numbers in the matrix. Schedule your function using loops, DO NOT use the predefined functions allowed Matlab: min, max, sort, sortRows. (C) The temperature distribution in a square metal plate when heated in the corner corresponding to coordinates x = y = L can be represented as: [the equation is in the photo that I upload]
Where To is the applied temperature, L is the side of the plate, and x and y coordinates where one wants to find temperature. Write a program that: • We ask the user the applied temperature, the length of the plate, and the number of divisions per side.(inputs) • Create a matrix with the temperature distribution in the plate. • Present graphically the matrix obtained by 3 figures as shown below (also in the uploaded photo) (the Figures were generated using the surf, imagesc, contourf, CLABEL commands - investigate the use of these commands in the help of matlab) Thanks a lot!
  2 Commenti
Jan
Jan il 28 Ott 2016
Modificato: Jan il 28 Ott 2016
Please, Anthony, show what you've tried so far and ask specific questions. We will not solve your homework. You know, that it would be cheating if you copy a solution given here.

Accedi per commentare.

Risposte (1)

jupiter
jupiter il 28 Ott 2016
Of Course, it will take a while to write the whole function, but just a few hints on how you can proceed : 1. For finding average, you can run the loop over whole array and everytime add the element to one predefined variable called 'sum' whose value is zero initially. for ...... sum = sum+element; end something like this. After the loop ends, you can find the average using : average = sum/size(array).
2: To find the maxima and minima, you define 2 variables maxima and minima whose inital values will be the first element of the array. In every loop compare the value of maxima and minima with the array elements and if the element > maxima, maxima = element AND if the element<minima, minima = element. If these conditions do not satisfy, the maxima and minima stay the same for next loop also. The value you get at the end of the loop is the maximum and minimum value of the array.
3. I am not able to see any attachment/figure.

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by