How can i populate an array using a for loop?

I need to create a 1D array of n elements. The array needs to be populated with a different random number in each element using a for loop. So far, I have:
prompt = 'Enter a value for n:' ; n = input(prompt); for i = 1:n A(1,i) = rand end
It's not quite working right. Any tips?

Risposte (1)

Categorie

Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange

Tag

Richiesto:

il 5 Dic 2014

Risposto:

il 6 Dic 2014

Community Treasure Hunt

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

Start Hunting!

Translated by