How to dynamically name variables based on a list and assign arrays from a cell array

2 ビュー (過去 30 日間)
Sven
Sven 2013 年 9 月 22 日
Hi, I have two elements I would like to combine:
A 1x5 Cell Array called Input with the variables names I want to use:
Input ={'Type','Characteristics','PortfolioMKV','PortfolioRet','StartDate'}
And a 1x5 Cell Array called AllRanges with the data I want to assign to the variable names above:
AllRanges = 'RB' { 4x54 cell} { 2x39 cell} { 2x39 cell} '7/31/2013'
So, I want to dynamically create/ assign the following:
Type = 'RB' Characteristics = { 4x54 cell} PortfolioMKV = { 2x39 cell} PortfolioRet = { 2x39 cell} StartDate = '7/31/2013'
Any idea how I can achieve this? Thanks
  1 件のコメント
Matt J
Matt J 2013 年 9 月 22 日
編集済み: Matt J 2013 年 9 月 22 日
Once you've dynamically created these variables, won't you also need a dynamic way of accessing/manipulating them later? How were you planning to do that? Was that going to be a follow-up question?

サインインしてコメントする。

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 9 月 22 日

Image Analyst
Image Analyst 2013 年 9 月 22 日
  4 件のコメント
Image Analyst
Image Analyst 2013 年 9 月 22 日
No, not unless you hard code the names in there or go against the recommendations laid out in the FAQ.
Jan
Jan 2013 年 9 月 22 日
@Sven: Please read the linked FAQ topic again until it gets clear to you. Do not create variables dynamically. This produces more troubles than it solves.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeVariables についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by