Thread Subject:
Very Simple Question

Subject: Very Simple Question

From: Casey

Date: 8 Sep, 2012 13:46:08

Message: 1 of 3

At least it will be for you all, I'm sure! I'm in an intro to programming class right now, and I'm having trouble with loops.

1) Create a new cell array with 100 cells, and every other cell having your name in it using a for loop. Then use a while loop instead.

So far I've gotten my cell array with 100 cells. But I'm stuck there. I've been Google-ing and trolling Matlab but haven't found anything helpful. I have figured out how to pull out every other number (in the fashion of: columns 1 through 10: 1 3 5 7 etc...) But, I'm pretty sure that's not even close to how I should be beginning this.

Any advice on how to do this is greatly appreciated...

Subject: Very Simple Question

From: dpb

Date: 8 Sep, 2012 14:16:17

Message: 2 of 3

On 9/8/2012 8:46 AM, Casey wrote:
> At least it will be for you all, I'm sure! I'm in an intro to
> programming class right now, and I'm having trouble with loops.
> 1) Create a new cell array with 100 cells, and every other cell having
> your name in it using a for loop. Then use a while loop instead.
>
> So far I've gotten my cell array with 100 cells. But I'm stuck there.
> I've been Google-ing and trolling Matlab but haven't found anything
> helpful. I have figured out how to pull out every other number (in the
> fashion of: columns 1 through 10: 1 3 5 7 etc...) But, I'm pretty sure
> that's not even close to how I should be beginning this.
>
> Any advice on how to do this is greatly appreciated...

OK, at least you're up front on the homework... :)

cs-sm is generally "show your work to date" first and then hints are
forthcoming...

I'd give the first hint as

doc colon

Read the "Getting Started" documentation section starting from the
beginning working your way through the 'Quick Start' section and then
particularly in "Language" the "Indexing" subject entry will be
enlightening...

--

Subject: Very Simple Question

From: dpb

Date: 8 Sep, 2012 14:28:51

Message: 3 of 3

On 9/8/2012 9:16 AM, dpb wrote:
> On 9/8/2012 8:46 AM, Casey wrote:
...

>> 1) Create a new cell array with 100 cells, and every other cell having
>> your name in it using a for loop. Then use a while loop instead.
>>
...

Then, to show off and use Matlab as intended, do it w/o a loop at all! :)

I'd add re: a general approach--give up the googling and all for a
solution to your problem but instead begin as suggested by reading the
online documentation and whatever other material the class syllabus has
recommended and work on picking up the basic underlying concepts so you
can apply them to the problem at hand.

Even if you do happen to stumble onto the particular question answer
that way it doesn't do much for actually developing the skill set in
question...

There's another newsgroup w/ a new participant who's trying to move some
C/C++ code to Fortran who's a apparently at lest familiar w/ C but who
keeps asking the most basic questions of Fortran after explaining he's
spent hours searching the internet...problem is, he's been told
repeatedly to get a language reference manual and even better a text and
learn something about the language itself. The lesson unfortunately
doesn't seem to be taking and he's still floundering around after a
couple of weeks trying to write Fortran in a C idiom and unable to
answer the most trivial of syntax questions because he won't use the
tools available directly addressing the core of the problem but looks to
find a specific question answered for him. One of the problems in that
approach is that not knowing the idioms his queries are malformed or use
the wrong terms--

OK, lecture over... :)

--

--

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.

rssFeed for this Thread

Contact us