Answered

next prime number using While loops

function k=next_prime(n) k=k+1 while ~isprime(k) k=k+1 end end

next prime number using While loops

function k=next_prime(n) k=k+1 while ~isprime(k) k=k+1 end end

4 months ago | 0

Answered

Write a function called halfsum that takes as input an at most two-dimensional matrix A and computes the sum of the elements of A that are in the diagonal or are to the right of it. example, the input is [1 2 3; 4 5 6; 7 8 9],the ans is 26

function summa=halfsum(a) [m,n]=size(a) for i=1:m j=1:n x(i)=sum(a(i,j)) end summa=sum(x) end

Write a function called halfsum that takes as input an at most two-dimensional matrix A and computes the sum of the elements of A that are in the diagonal or are to the right of it. example, the input is [1 2 3; 4 5 6; 7 8 9],the ans is 26

function summa=halfsum(a) [m,n]=size(a) for i=1:m j=1:n x(i)=sum(a(i,j)) end summa=sum(x) end

4 months ago | 0

Answered

Write a function called under_age that takes two positive integer scalar arguments: age that represents someone's age, and limit that represents an age limit. The function returns true if the person is younger than the age limit. If the second arg

function [a]=under_age(n,m) a=n<m; if a==1; fprintf('true') end if nargin<2; m=21; end end

Write a function called under_age that takes two positive integer scalar arguments: age that represents someone's age, and limit that represents an age limit. The function returns true if the person is younger than the age limit. If the second arg

function [a]=under_age(n,m) a=n<m; if a==1; fprintf('true') end if nargin<2; m=21; end end

4 months ago | 0

Answered

How to write function for above combine matrix?

function T=trio(n,m) a=ones(n,m);b=2*a;c=3*a; T=[a;b;c]; end

How to write function for above combine matrix?

function T=trio(n,m) a=ones(n,m);b=2*a;c=3*a; T=[a;b;c]; end

5 months ago | 1

Answered

Write a function called minimax that takes M, a matrix input argument and returns mmr, a row vector containing the absolute values of the difference between the maximum and minimum valued elements in each row. As a second output argument called mmm,

function [a,b]=minimax(M) [m,n]=size(M); x=1:m; a=max(M(x,:)')-min(M(x,:)'); v=M(:); b=max(v)-min(v); end

Write a function called minimax that takes M, a matrix input argument and returns mmr, a row vector containing the absolute values of the difference between the maximum and minimum valued elements in each row. As a second output argument called mmm,

function [a,b]=minimax(M) [m,n]=size(M); x=1:m; a=max(M(x,:)')-min(M(x,:)'); v=M(:); b=max(v)-min(v); end

5 months ago | 0