Why do I get a different result when running code in editor vs. in command window?

2 views (last 30 days)
I have a very strange bug which I cant seem to fix. When I run the following code in either the editor or the command window I get different results. One results in a simple cell array of doubles (when running in editor window) and one results in a array of complex doubles (when running in command window).
The code is:
pre_h_hursts = zeros(1,length(file_list));
for p = 1:length(file_list)
pre_h_hursts_parts = dfaedit(a_pre_h{1,p},0,0,0);
pre_h_hursts(1,p) = pre_h_hursts_parts;
The results of running the code in the editor (as a section within a larger script) are saved in the files "editor_pre_h_hursts.mat" and "editor_pre_h_hursts_parts.mat" and the results from running the code in the command window are saved in the files "command_pre_h_hursts.mat" and "command_pre_h_hursts_parts.mat".
Does anyone have an idea why this is?
EDIT: I also found the that when I run the code in a new editor window in a new script (not part of a longer script) I also get the array of complex doubles as a result.

Answers (0)


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

Community Treasure Hunt

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

Start Hunting!

Translated by