Can a scrip/function be written to navigate and edit data in the variables editor window using Matlab?

3 views (last 30 days)
See Title, and if yes, how.

Accepted Answer

Mehmed Saad
Mehmed Saad on 22 Jul 2020
Edited: Mehmed Saad on 22 Jul 2020

Option-1

You can do that using openvar and dbstop
x = rand(1,5);
openvar('x');
dbstop at 4
bpl = 1; % break point line
Now suppose i edited x and change values or add values in it. As the code is in debugging mode, either press F5 on keyboard or Continue from Editor window
y = x*5+0.75;

Option-2

You can create GUI
  4 Comments
Henri Carpentier
Henri Carpentier on 24 Jul 2020
Hi Again,
I am looking into creating a GUI. I have not done that before and doing so seems interesting so I will look into it and see what is involved. Thank you for your assistance.
Sindar
Sindar on 27 Jul 2020
Depending on how consistent your new data will be, a function might be easier:
function y = mean_adjust_x(x_base,idx,new_elems)
%mean_adjust_x takes a vector x_base, replaces elements at indices idx with new_elems
% works with idx and new_elems as matching-length vectors
if max(idx) <= numel(x) && length(idx) == length(new_elems)
x = x_base;
x(idx) = new_elems;
% or new_elems being a scalar
elseif max(idx) <= numel(x) && length(new_elems) == 1
x = x_base;
x(idx) = new_elems;
% so long as idx is compatible with x_base
else
error('idx value goes above size of x_base')
end
% do whatever you want to x, in this case taking the mean
y = mean(x);
end
Then you could call it like this:
% create a base x
x = 1:100;
% decide that you'll replace some values with 0
new_elem = 0;
% take the mean replacing the 5th element
y = mean_adjust_x(x,5,new_elem)
% take the mean replacing every 6th element
y = mean_adjust_x(x,[6:6:100],new_elem)

Sign in to comment.

More Answers (1)

Henri Carpentier
Henri Carpentier on 28 Jul 2020
Hi Mehmed,
I am still going through your programming suggestion but I went with a script in lieu of a function but I can go either way. I have a 1000 by 10 array of numbers (not a table although I'm rethinking a table may be easier because it permits the use of the "tail" function, which doesn't want to work with my array). I want to go to the 1001 row which is empty and and then enter 10 new numbers and have it saved to that particular variable in the workspace. Since there are so many rows (not considered a tall array yet) I don't want to bring it all into the command window and do what I gotta do because thats a lot of rows to display.
I've been thinking about this problem over the last several days and I think of new things to try every now and then. Maybe my real problem is bringing in the last row or the empty row, to the command window, from my large variable in the workspace, skipping down a row to the empty row, make my entries have it saved to the original variable and not replace it. Or maybe I just want to make the entires in the command window and append/merge it to the end of the appropriate variable in the workspace.
I know I'll figure this our eventually and kick myself because it was so simple to do in the first place. I don't spend much time on this problem because manually I can do what I want to get the results I need, and because I have more fun things to do. But thank you for your responses.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!