How to save workspace variables in a cell array at specific location (Example: C{1,1}(1,1)) in the same workspace?

1 次查看(过去 30 天)
I want to save a workspace variable at location C{1,1}(1,1) in a cell array which is present in the same workspace. I used this command. It executes in command window but the same logic fails in editor window when written at button callback.
M = 1:10;
M = M';
C = {M};
assignin('base','C',C);
C{1,1}(1,1) = 55;
  3 个评论
N/A
N/A 2017-5-4
Can you please tell me how can i save value at a specific location in a cell array. this only executes in command window but not in editor
c{1,1}(1,1) = 42;
Stephen23
Stephen23 2017-5-4
@Tanzeela Javid: and what happens when you try to execute that line? Do you get a warning, or an error, or the wrong value, or something else...? If you get any warning/error message then please show us the complete message. If it runs but gives an incorrect value (or something else...) then please tell us what you expect and what it does.

请先登录,再进行评论。

回答(2 个)

N/A
N/A 2017-5-5
This is the error msg when I execute this code.
x=evalin('base',value1); y=evalin('base', value2); assignin('base',C{1,1}(1,1),x); assignin('base',C{1,1}(2,1),y);
  4 个评论
Stephen23
Stephen23 2017-5-5
@Tanzeela Javid: I gave you some links to look at. Personally I think using nested functions is a very easy way to share data between callbacks. Give them a try.

请先登录,再进行评论。


N/A
N/A 2017-5-5
%reading value from workspace
x = evalin('base','value1');
y = evalin('base','value2');
assignin('base',C{1,1}(1,1),x);
assignin('base',C{1,1}(2,1),y)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by