フィルターのクリア

renaming variable on workspace with string from cell of catalogue

1 回表示 (過去 30 日間)
DuckDuck
DuckDuck 2012 年 6 月 18 日
i enter to a promt the name of my variable. that name is stored in a cell of catalogue. I want to use that name to rename my matrix after calculations. How can i do that?
this is my code:
prompt = {'Enter start time:','Enter stop time:','Enter segment name'};
dlg_title = 'Segment signal';
num_lines = 1;
def = {'','','r1s1'};%default values of promt where the first is start time, stop time and segment name
input = inputdlg(prompt,dlg_title,num_lines,def); %add entered promt to cell
input1=str2num(char(input(1:2))); %convert the 2 parameters to number
%start=472; %start time of the segment
%stop=607; %stop time of the segment
list=(input1(1)<t1)&(t1<input1(2));%get rows where condition is met
[,list1]=find(list>0);%get id of the rows where condition is met
% get values for the segment
p(:,1)=t1(list1); %get time
p(:,2)=acc1(list1,3); %get value
%i want to rename p to r1s1 or whatever i enter into the promt

採用された回答

Sean de Wolski
Sean de Wolski 2012 年 6 月 18 日
You don't really want to do that! For the same reasons that you don't want to create A1 A2 ... An in a loop
If you actually want to do this, which, like I said, you don't (!), you can use eval()
  6 件のコメント
Walter Roberson
Walter Roberson 2012 年 6 月 18 日
input(3) is a cell array, not a string. Use input{3}
DuckDuck
DuckDuck 2012 年 6 月 18 日
yep that was the thing :)
i accept your answer.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by