1.
function A = sq()
A = [];
for i = 1: 10
A = [A i*i];
end
end
![= sq.m RUN Vars [1x10] ans 1 function Asq() for i-1:10 end 6 end 10 octave: 12> sq() ans = 4 91625 3649 64 8110e](http://img.homeworklib.com/questions/0fca04e0-b0e5-11eb-b28b-79b1b6cc1c7c.png?x-oss-process=image/resize,w_560)
2.
function terms = sumterms()
sum = 0;
terms = 0;
i = 1;
while true
sum = sum + i;
if sum <= 100
terms = terms + 1;
i = i+1;
else
break;
end
end
end

3.
function X = matrixop(n)
X = zeros(n)
for row = 1:n
for col = 1:n
X(row,col) = sin (1/(row+col-1));
end
end
end
![matrixop.m RUN Vars octave: 16> matrixop (5) [5x5] ans 1 function Xmatrixop (n) x-zeros (n) for row1:n 4 for col-1:n X(row, c](http://img.homeworklib.com/questions/10967100-b0e5-11eb-895d-25c4faa2bc19.png?x-oss-process=image/resize,w_560)
Solve using Matlab Write a simple loop to list the squares of the first 10 integers....
3. [20 points] Write a simple Matlab for-loop that adds up the squares of the elements of a vec tor V of length N. Variable Sumofy will contain the sum of the elements.
MATLAB
homework assignment (HW6), but this time using a "vectorized" approach. Write a script that prompts the user for N integers (set N-6), one at a time, using a while loop. Error-check to ensure that each number entered is an integer, displaying an error message if it is not. If it is an integer, store it in an array variable nums. Continue prompting until N integers have been successfully entered. (You may copy and paste your code from the previous...
In MATLAB
Write a script to determine the number of terms required for the sum of the series (5k? – 2k) not to exceed 100,000 using the while loop. Display the number of terms and the calculated sum using fprint () command as follow: The number of terms is 38 and its sum is 93613
Write a MATLAB script, using either a single or nested for-loop, that will print the factorials for the numbers between 1 and 100 (inclusive). The factorial of n (n!) is the product of the positive integers less than or equal to n. For example: 3! = 3 * 2 * 1. For this question you cannot use the built-in MATLAB factorial function, but you can use other MATLAB functions if you wish. MATLAB code!MATLAB code!MATLAB code!MATLAB code!
answer 4, 5, 6, 7 using matlab
Homework 10 1. Write the correct first-line syntax for a user defined function that is named Feynman and has input variables q and e, and outputs L and M. (Comment out of this line). 2. Using zeros, ones, and eye commands write the one line syntax to create the following matrix: 00000 01100 01010 01001 3. Write the syntax for the user defined function that calculates the surface area and volume of a...
MATLAB
Write a script without using any loops to calculate e^5 for N =
10 using only array operations and sum() function.
- rn n-0
(+30) Provide a python program which will Populate an array(list) of size 25 with integers in the range -100 (negative 100) to +100 inclusive Display the array and its length (use the len function) Display the average of all the integers in the array Display the number of even integers (how many) Display the number of odd integers (how many) Display the number of integers > 0 (how many) Display the number of integers < 0 (how many) Display the...
run/call tle un/cd to compute the sum of the first 15 terms of the series: th (b) It is desired 14 n3 - 20 n2 + 5n, 110) 1,2,..15 n Develop a pseudocode of the required program. roposed algorithm in a flow chart if it is solved using a for loop ow the p () Write a MATLAB script file using for loop
run/call tle un/cd to compute the sum of the first 15 terms of the series: th (b)...
17. (2 points) C++ Using a while loop, write the code statements to sum 10 integers entered by a user. Display the sum. Hint: Be sure to declare, initialize, and use appropriate variables to count the repetitions and accumulate the sum.
Flowcharts & for loops 1. Using a for loop, write a MatLab script to convert ounces to grams for 0 to 16 ounces, in 1-ounce increments. Present output in a table; label columns appropriately. 2. A Fibonacci sequence is composed of elements created by adding the previous 2 elements. The simplest Fibonacci sequence starts with 1, 1 and proceeds as follows: 1,1,2,3,5,8… Element 3 is the sum of elements 1 and 2 (1+1=2) Element 4 is the sum of elements...