"Jessica " <jyorzinski@ucdavis.edu> wrote in message
<fvn3hr$di3$1@fred.mathworks.com>...
> Hi,
>
> As a simplified example, I am trying to use a loop to fill
> in values of a data array as follows:
>
> data = [];
> p =input('Enter a number: ');
>
> for NumberofCalls = 1:p
> data {p,1} = '3';
> data{p,2} = '2';
> end;
>
>
> I would like to end up with a matrix when p=2:
>
> 3 2
> 3 2
>
> but instead I get:
>
> [] []
>
> '3' '2'
>
>
> Is there a way to modify the code to get what I am after?
>
> Thanks!
You made a mistake you must use NumberofCalls in your loop :
for NumberofCalls = 1:p
data {NumberofCalls,1} = '3';
data{NumberofCalls,2} = '2';
end
and are you sure that you want to put string and to have a
Cell array ?
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Disclaimer prior to use.