how can i convert an integer to an array in this function?

33 views (last 30 days)
function a=get_array_num(n)
requirments: loops,if,recurion or logical operatos num2str or str2num
3.length_of(n)=number of digits in "n" (help function)
i think maybe logspace is useful here...but how?
Jan on 2 Apr 2013
For length_of() the log10 function would be much smarter.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 31 Mar 2013
How about
a = zeros(n);
a = n * ones(1, 10);
or something similar? There is an infinite variety of arrays you could make that would full those requirements, though requirement #3 is not well explained at all (no idea what it even means).
Jan on 2 Apr 2013
@Zaza: It consumed some time and energy to bring you to post an explicit example. We get some parts of the problem distributed to the question and over several comments. Therefore an efficient answer is impossible.
Please edit the original question and insert all available information. Then show us, what you have tried so far, because of course we are not going to solve your homework: you couldn't submit it anymore without cheating!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by