Feeds
已回答
I am working on homework but i cannot figure out what is wrong
whenever you do array multiplication the no of elements in both array must be same or multiply with a constt number with array o...
I am working on homework but i cannot figure out what is wrong
whenever you do array multiplication the no of elements in both array must be same or multiply with a constt number with array o...
5 years 前 | 0
已回答
How do I calculate the difference between the elements of two vectors given a condition ?
for given vector x and y; x= [106, 306, 407, 607] % given x vector y = [101, 201, 301, 401, 501] %givrn y vector d=[]; for...
How do I calculate the difference between the elements of two vectors given a condition ?
for given vector x and y; x= [106, 306, 407, 607] % given x vector y = [101, 201, 301, 401, 501] %givrn y vector d=[]; for...
5 years 前 | 0
| 已接受
已回答
Coding taylor approximation of natural log
if you want to calculate log(1.9) and x=0.9 then you have apply taylor series log(1+x) see formula form google and change in to ...
Coding taylor approximation of natural log
if you want to calculate log(1.9) and x=0.9 then you have apply taylor series log(1+x) see formula form google and change in to ...
6 years 前 | 0
已回答
Write a function called fare that computes the bus fare one must pay in a given city based on the distance travelled. Here is how the fare is calculated: the first mile is $2. Each additional mile up to a total trip distance of 10 miles is 25 cents.
function Kcost= fare(d, A) d=round(d); %rounding the distance to nearest positive integer if d <=1 Kcost=2; %for f...
Write a function called fare that computes the bus fare one must pay in a given city based on the distance travelled. Here is how the fare is calculated: the first mile is $2. Each additional mile up to a total trip distance of 10 miles is 25 cents.
function Kcost= fare(d, A) d=round(d); %rounding the distance to nearest positive integer if d <=1 Kcost=2; %for f...
6 years 前 | 0
已回答
Write a function called day_diff that takes four scalar positive integer inputs, month1, day1, month2, day2. These represents the birthdays of two children who were born in 2015. The function returns a positive integer scalar that is equal to the dif
function dd=day_diff(m1,d1,m2,d2) num_of_days=[31,28,31,30,31,30,31,31,30,31,30,31]; dd=-1; mmm1=round(m1);...
Write a function called day_diff that takes four scalar positive integer inputs, month1, day1, month2, day2. These represents the birthdays of two children who were born in 2015. The function returns a positive integer scalar that is equal to the dif
function dd=day_diff(m1,d1,m2,d2) num_of_days=[31,28,31,30,31,30,31,31,30,31,30,31]; dd=-1; mmm1=round(m1);...
6 years 前 | 0
已回答
How to do it?
function s=halfsum(a) [m,n]=size(a); s=0; a=flip(a); for r=1:m for c=n:-1:r s=s+a(r,c); end en...
How to do it?
function s=halfsum(a) [m,n]=size(a); s=0; a=flip(a); for r=1:m for c=n:-1:r s=s+a(r,c); end en...
6 years 前 | 0
已回答
Write a function called spiral_diag_sum that takes an odd positive integer n as an input and computes the sum of all the elements in the two diagonals of the n-by-n spiral matrix. For example, starting with the number 1 and moving to the right in a c
function sd=spiral_diag_sum(n) s1=0; s2=0; a=spiral(n); for r=1:n %for below the diagonal elements s1=s1+su...
Write a function called spiral_diag_sum that takes an odd positive integer n as an input and computes the sum of all the elements in the two diagonals of the n-by-n spiral matrix. For example, starting with the number 1 and moving to the right in a c
function sd=spiral_diag_sum(n) s1=0; s2=0; a=spiral(n); for r=1:n %for below the diagonal elements s1=s1+su...
6 years 前 | 0
已回答
A function called small_elements that takes as input an array named X that is a matrix or a vector. Could you help me to understand the meaning?
function ind=small_elements(v) [m,n]=size(v); j=0; ind=[]; for c=1:n for r=1:m if (r*c) > v(r,c) ...
A function called small_elements that takes as input an array named X that is a matrix or a vector. Could you help me to understand the meaning?
function ind=small_elements(v) [m,n]=size(v); j=0; ind=[]; for c=1:n for r=1:m if (r*c) > v(r,c) ...
6 years 前 | 0
已回答
Indexing & Move Me function
function out= move_me(v,a) s=length(v); if nargin < 2 %for validation of input a=0; end for x=1:s if v(x)==a %co...
Indexing & Move Me function
function out= move_me(v,a) s=length(v); if nargin < 2 %for validation of input a=0; end for x=1:s if v(x)==a %co...
6 years 前 | 0
已回答
How to transform years into centuries
function s= centuries(n) p={'I','II','III','IV','V','VI','VII','VIII','IX','X','XI','XII','XIII','XIV','XV','XVI','XVII',' XVII...
How to transform years into centuries
function s= centuries(n) p={'I','II','III','IV','V','VI','VII','VIII','IX','X','XI','XII','XIII','XIV','XV','XVI','XVII',' XVII...
6 years 前 | 0
已回答
Write a function called integerize that takes as its input a matrix A of integers of type double, and returns the name of the “smallest” signed integer class to which A can be converted without loss of information.
function cls=integerize(a) if isscalar(a) if a>0 mina=0; maxa=a; else maxa=0; min...
Write a function called integerize that takes as its input a matrix A of integers of type double, and returns the name of the “smallest” signed integer class to which A can be converted without loss of information.
function cls=integerize(a) if isscalar(a) if a>0 mina=0; maxa=a; else maxa=0; min...
6 years 前 | 0
已回答
Hey Guys can you help me with that.
function s2=dial(n) p=[n]; s1=''; tx = ismember(p, ['A':'Z','0':'9']);%only digits and capital letters tx1=sum(tx); if leng...
Hey Guys can you help me with that.
function s2=dial(n) p=[n]; s1=''; tx = ismember(p, ['A':'Z','0':'9']);%only digits and capital letters tx1=sum(tx); if leng...
6 years 前 | 0
已回答
Each number on telephone keypads, except 0 and 1, corresponds to a set of uppercase letters as shown in this list: 2 ABC, 3 DEF, 4 GHI, 5 JKL, 6 MNO, 7 PQRS, 8 TUV, 9 WXYZ Hence, a phone-number specification can include uppercase letters and digits.
function s2=dial(n) p=[n]; s1=''; tx = ismember(p, ['A':'Z','0':'9']);%only digits and capital letters tx1=sum(tx); if leng...
Each number on telephone keypads, except 0 and 1, corresponds to a set of uppercase letters as shown in this list: 2 ABC, 3 DEF, 4 GHI, 5 JKL, 6 MNO, 7 PQRS, 8 TUV, 9 WXYZ Hence, a phone-number specification can include uppercase letters and digits.
function s2=dial(n) p=[n]; s1=''; tx = ismember(p, ['A':'Z','0':'9']);%only digits and capital letters tx1=sum(tx); if leng...
6 years 前 | 0
已回答
Can anyone help me with this question..?
function s2=dial(n) p=[n]; s1=''; tx = ismember(p, ['A':'Z','0':'9']);%only digits and capital letters tx1=sum(tx); if leng...
Can anyone help me with this question..?
function s2=dial(n) p=[n]; s1=''; tx = ismember(p, ['A':'Z','0':'9']);%only digits and capital letters tx1=sum(tx); if leng...
6 years 前 | 0
已回答
Write a function called digit_counter that takes the name of a text file as input and returns the number of digits (i.e., any of the characters, 0-to-9) that the file contains. If there is a problem opening the file, the function returns -1.
function d=digit_counter(filename) fid=fopen(filename,'r'); if fid<0 d=-1; else A = char(fr...
Write a function called digit_counter that takes the name of a text file as input and returns the number of digits (i.e., any of the characters, 0-to-9) that the file contains. If there is a problem opening the file, the function returns -1.
function d=digit_counter(filename) fid=fopen(filename,'r'); if fid<0 d=-1; else A = char(fr...
6 years 前 | 0
已回答
Write a function called circular_primes that finds the number of circular prime numbers smaller than n, where n is a positive integer scalar input argument. For example, the number, 197, is a circular prime because all rotations of its digits:
function out=circular_primes(no) prim=primes(no);% find the all prime number till the given number pr=0; nos=[]; po=[]; for...
Write a function called circular_primes that finds the number of circular prime numbers smaller than n, where n is a positive integer scalar input argument. For example, the number, 197, is a circular prime because all rotations of its digits:
function out=circular_primes(no) prim=primes(no);% find the all prime number till the given number pr=0; nos=[]; po=[]; for...
6 years 前 | 0
已回答
How can I solve this problem?
function out=circular_primes(no) prim=primes(no);% find the all prime number till the given number pr=0; nos=[]; po=[]; for...
How can I solve this problem?
function out=circular_primes(no) prim=primes(no);% find the all prime number till the given number pr=0; nos=[]; po=[]; for...
6 years 前 | 0
已回答
Number of first days of the month equals to Mondays
function counter=day_counter(y) counter=0; year=rem(y,100); % no of years in century lp=fix(year/4); %leap year if y~=19...
Number of first days of the month equals to Mondays
function counter=day_counter(y) counter=0; year=rem(y,100); % no of years in century lp=fix(year/4); %leap year if y~=19...
6 years 前 | 0