Suppressed variable shows in command window when using "run" button, but doesn't show when using "run and advance"

4 views (last 30 days)
Hey all,
I am using MATLAB 2018b and when I run a script using the "Run" button it displays the variable in the command window at the end of my script, even though the variable has been suppressed. However, this does not occur when I use the "Run and Advance" button. Any thoughts on what is going on here? The variable UM1_272E_r, which is defined as y at the begining of the script is displayed in the command window after the "average_fit_error" answer. Not sure why?
% Clear all
clear % Clears workspace.
clc % Clears command window.
%% Data
% Imports the array data (x and y) to the workspace by loading Excel data
% that has been imported and converted to *.mat format.
load('UM1_272R_r'); % y data.
load('degrees'); % x axis data = 0:0.1802:360.2198
% (starts at 0 and goes to 360.2198 in steps of .1802.
x = degrees; % Quadrants in degrees
y = UM1_272R_r; % Cylinder profile data
%% Plot Proflile
plot(x,y)
%% Remove Linear & Non-linear Trends
% This section is in the regular algorithm, but the profile data used for
% this set was already de-trended
subplot(2,1,1)
plot(x,y)
hold on
opol =3;% Sets order of the polynomial.
[p,s,mu] = polyfit(x,y,opol);% Polyfit function.
f_y = polyval(p,x,[],mu);% Returns values of the best fit polynomial.
% To see how good the fit is, evaluate the polynomial at the data
% points and generate a table showing the data, fit, and error.
T = table(x,y,f_y,y-f_y,'VariableNames',{'X','Y','Fit','FitError'});
y = y - f_y; % Subtracts the best fit polynomial from the data.
% Returns the average fit error for the fit polynomial of order "opol".
average_fit_error = abs(mean(y))
subplot(2,1,1)
plot(x,f_y)
title(['Poly order ' num2str(opol),' Error ' num2str(average_fit_error)])
%% Plot Best Fit Curve
subplot(2,1,2)
plot(x, y)
title(['Poly order ' num2str(opol),' subtracted'])
variable display error.tiff

Answers (1)

Ron Perrone
Ron Perrone on 13 Jun 2019
Hey all,
I figured it out. It was a naming issue. To correct this, I changed the name of the script (which was named UM1_272R_r) and added ".mat" to the two loads. This corrected the issue. I still am not sure exactly why this was occuring, but this resolved it. But I still wouldn't mind knowing why this occured.
RP

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!