"Luca Cerone" <luca_cerone#_remove_this#@yahoo.it> wrote in message <i0suvg$eou$1@fred.mathworks.com>...
> Hi everybody,
> I'm sorry if the question is silly,
> but I couldn't find in the help nor in the newsgroup.
>
> I've a vector v and have to assign its values to different variables,
> something like:
>
> a=v(1);
> b=v(2);
> c=v(3);
> .
> .
> .
> and so on.
>
> Is there any easy way to write such a piece of code?
> Thanks a lot in advance to you all.
> Cheers, -Luca

Hi Luca,

I wonder your use of this thing..

Hint..

Go for Doc char
Then look for ASCII characters from 97.,...122
May it helps
Regards
Faraz

"Luca Cerone" <luca_cerone#_remove_this#@yahoo.it> wrote in message <i0suvg$eou$1@fred.mathworks.com>...
> Hi everybody,
> I'm sorry if the question is silly,
> but I couldn't find in the help nor in the newsgroup.
>
> I've a vector v and have to assign its values to different variables,
> something like:
>
> a=v(1);
> b=v(2);
> c=v(3);
> .
> .
> .
> and so on.
>
> Is there any easy way to write such a piece of code?
> Thanks a lot in advance to you all.
> Cheers, -Luca

well... since you're a seasoned ML/CSSM user, let's assume you have very good reason for doing this...

Thanks guys,
but actually I wanted to know if there is a built-in function..
similar to the deal for cells!
As we're talking, why wouldn't you suggest to assign variables
such a way?
I have a vector vec of parameters (I get it from fmincon).
I have to use these parameters into an ode,
so instead of remembering the order of the parameters
in the vector I prefer to create a function [a1,a2,a3]=setParam(param)
that assign the right value to each parameter.
This way if I make a mistake I only have to change the setParam function
instead of looking in the code everytime I'm using it.
If there is a more effective/elegant way any advice is accepted!
Cheers, -Luca

> I have to use these parameters into an ode,
> so instead of remembering the order of the parameters
> in the vector I prefer to create a function [a1,a2,a3]=setParam(param)
> that assign the right value to each parameter.
> This way if I make a mistake I only have to change the setParam function
> instead of looking in the code everytime I'm using it.
> If there is a more effective/elegant way any advice is accepted!

I suggest you consider using fields of a structure. You may wish to use
cell2struct to build the structure.

>Converting to cell and using deal on the {:} of the
cell is the only mechanism for mass assignment.

That's unfortunate. I see in Python that mass assignment from numeric vectors is quite common and normal. For example, here's a snip from the following Machine Learning example. Contra all the doubters in this thread, it seems very compact and readable:

"Brad Stiritz" wrote in message <n430qr$d7a$1@newscl01ah.mathworks.com>...
> >Converting to cell and using deal on the {:} of the
> cell is the only mechanism for mass assignment.
>
> That's unfortunate. I see in Python that mass assignment from numeric vectors is quite common and normal. For example, here's a snip from the following Machine Learning example. Contra all the doubters in this thread, it seems very compact and readable:
>
> xA,yA,xB,yB = [random.uniform(-1, 1) for i in range(4)]
>
> https://datasciencelab.wordpress.com/2014/01/10/machine-learning-classics-the-perceptron/

I realize the majority of this thread is old, but I'm compelled to agree with Brad and share my bewilderment at the number of objections to the notion that vector elements might benefit greatly from separate names. If I e.g. solve a system of equations modeling an actual physical system, there's a strong chance that the elements of the solution are distinct variables and may even have completely independent futures.

Consider the toy example of two massses hanging on a string over a pulley. If one were to solve the 2x2 system for tension and acceleration, obviously those things should have discernible names like "T" and "a", not "v(1)" and "v(2)", for clarity and for the purposes of subsequent calculations.

Is this really such an uncommon thing in general programming? Doing particle physics, I use this concept (in python) *at least as often* as naming the vector collectively.

"Matt Severson" wrote in message <nb7g93$4m2$1@newscl01ah.mathworks.com>...
> "Brad Stiritz" wrote in message <n430qr$d7a$1@newscl01ah.mathworks.com>...
> > >Converting to cell and using deal on the {:} of the
> > cell is the only mechanism for mass assignment.
> >
> > That's unfortunate. I see in Python that mass assignment from numeric vectors is quite common and normal

I also use this approach for code readability/clarity. My solution was to create a small utility function:

What is a watch list?

You can think of your watch list as threads that you have bookmarked.

You can add tags, authors, threads, and even search results to your watch list. This way you can easily keep track of topics that you're interested in. To view your watch list, click on the "My Newsreader" link.

To add items to your watch list, click the "add to watch list" link at the bottom of any page.

How do I add an item to my watch list?

Search

To add search criteria to your watch list, search for the desired term in the search box. Click on the "Add this search to my watch list" link on the search results page.

You can also add a tag to your watch list by searching for the tag with the directive "tag:tag_name" where tag_name is the name of the tag you would like to watch.

Author

To add an author to your watch list, go to the author's profile page and click on the "Add this author to my watch list" link at the top of the page. You can also add an author to your watch list by going to a thread that the author has posted to and clicking on the "Add this author to my watch list" link. You will be notified whenever the author makes a post.

Thread

To add a thread to your watch list, go to the thread page and click the "Add this thread to my watch list" link at the top of the page.

About Newsgroups, Newsreaders, and MATLAB Central

What are newsgroups?

The newsgroups are a worldwide forum that is open to everyone. Newsgroups are used to discuss a huge range of topics, make announcements, and trade files.

Discussions are threaded, or grouped in a way that allows you to read a posted message and all of its replies in chronological order. This makes it easy to follow the thread of the conversation, and to see what’s already been said before you post your own reply or make a new posting.

Newsgroup content is distributed by servers hosted by various organizations on the Internet. Messages are exchanged and managed using open-standard protocols. No single entity “owns” the newsgroups.

There are thousands of newsgroups, each addressing a single topic or area of interest. The MATLAB Central Newsreader posts and displays messages in the comp.soft-sys.matlab newsgroup.

How do I read or post to the newsgroups?

MATLAB Central

You can use the integrated newsreader at the MATLAB Central website to read and post messages in this newsgroup. MATLAB Central is hosted by MathWorks.

Messages posted through the MATLAB Central Newsreader are seen by everyone using the newsgroups, regardless of how they access the newsgroups. There are several advantages to using MATLAB Central.

Use the Email Address of Your Choice
The MATLAB Central Newsreader allows you to define an alternative email address as your posting address, avoiding clutter in your primary mailbox and reducing spam.

Spam Control
Most newsgroup spam is filtered out by the MATLAB Central Newsreader.

Tagging
Messages can be tagged with a relevant label by any signed-in user. Tags can be used as keywords to find particular files of interest, or as a way to categorize your bookmarked postings. You may choose to allow others to view your tags, and you can view or search others’ tags as well as those of the community at large. Tagging provides a way to see both the big trends and the smaller, more obscure ideas and applications.

Watch lists
Setting up watch lists allows you to be notified of updates made to postings selected by author, thread, or any search variable. Your watch list notifications can be sent by email (daily digest or immediate), displayed in My Newsreader, or sent via RSS feed.

Other ways to access the newsgroups

Use a newsreader through your school, employer, or internet service provider

Pay for newsgroup access from a commercial provider

Use Google Groups

Mathforum.org provides a newsreader with access to the comp.soft sys.matlab newsgroup