Can a scrip/function be written to navigate and edit data in the variables editor window using Matlab?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Henri Carpentier
le 22 Juil 2020
Réponse apportée : Henri Carpentier
le 28 Juil 2020
See Title, and if yes, how.
1 commentaire
Sindar
le 22 Juil 2020
Why? What do you want to do that can only be done in the variable editor window?
Réponse acceptée
Mehmed Saad
le 22 Juil 2020
Modifié(e) : Mehmed Saad
le 22 Juil 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 commentaires
Sindar
le 27 Juil 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)
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Environment and Settings dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!