youssef
Followers: 0 Following: 0
Feeds
已回答
I want to write a recursive Function that can calculate the sum of all the digit. If the input is 12345 then the answer will be 1+2+3+4+5 , without using string2num and loop.
function x=digit_sum(n) x=0; if n<=0 x=0; else x=x+mod(n,10)+digit_sum((n-mod(n,10))/10); end end
I want to write a recursive Function that can calculate the sum of all the digit. If the input is 12345 then the answer will be 1+2+3+4+5 , without using string2num and loop.
function x=digit_sum(n) x=0; if n<=0 x=0; else x=x+mod(n,10)+digit_sum((n-mod(n,10))/10); end end
1 year 前 | 0
已回答
write a function called saddle in the input matrix M , the function should return with exactly two column vector and each row of output vector represent dimensions of saddle point in the input matrix M
function indices=saddle(M) indices=[]; [a,b]=size(M); rows=cell(a,1); %making the ceLLs for i=1:a rows{i,1}=M(i,:); e...
write a function called saddle in the input matrix M , the function should return with exactly two column vector and each row of output vector represent dimensions of saddle point in the input matrix M
function indices=saddle(M) indices=[]; [a,b]=size(M); rows=cell(a,1); %making the ceLLs for i=1:a rows{i,1}=M(i,:); e...
1 year 前 | 0