Matlabd variable is not chaning in workspace

All of a sudden my workspace is not updating values changed in the script file. It keeps restoring back to the orginal values. Could this be an issue with the file path? If so, how do you fix this>

댓글 수: 2

However, when I add a new variable above or below the line, the new variable is output into the workspace.
Voss
Voss 2023년 1월 3일
Can you upload your script (using the paperclip icon)?

댓글을 달려면 로그인하십시오.

답변 (2개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 1월 3일

1 개 추천

Start your code with:
clearvars

댓글 수: 3

Thank you for your response. I tried it and it seems to still come up with the old values. Even variables that have been commented out are still showing up.
can you share your code or the part of it where you have a problem?
I attached part of the code. I assigned variable values and then was saving the .mat file but it should be updating when the script file changes. I am also using the ode45 function with the assigned values. I am not sure if that helps explaint he issue.

댓글을 달려면 로그인하십시오.

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 1월 4일

1 개 추천

Michelle,
Looking at your attached code that recalls your system function and simulates it, I presume that you are working with homogenouse DE, correct?
If so, with your set initial conditions (ICs) and default error tolerances of ODE45, your simulation results (numerical solutions) will be only zeros. All ICs are M0_1 = [10e-19 10e-19 10e-19 10e-19 10e-19 10e-19 10e-19], which are almost zero. To might best knowldge, the default error tolerance (relative error) of ODE45 is 1e-3 that means with your set ICs (10e-19), the system response will not be different from "0". There is nothing to do with the path or directory or other syntax issues as I see here. It is all about your set ICs.
Therefore, suggeston 1 - change your set ICs to greater values.
suggestion 2 - set up ODE45 settings (relative and absolute error tolerances) using odeset() DOC.

댓글 수: 3

Michelle Bollini
Michelle Bollini 2023년 1월 5일
편집: Michelle Bollini 2023년 1월 5일
Thank you that is very helpful! It seems like there may be another issue with the workspace however. It is not updating when the script runs. For example, I attached a screenshot where I changes the IC but it keeps reverting to the old value, even when the variables are cleared with clearvars and selecting clear workspace. Thank you for all of your help, I really appreciate it.
Without looking at your code and/or a system equations, it is a bit difficult to guess how to resolve your issue.
Hi Sulaymon,
I figured out the issue! I was trying to look at the results in an excel file, so at the end I loaded the .mat file so that I can ouput the values. However, I think it kept replacing the values in the script. Silly mistake! I really apperciate all your help and information about the ode45 function.
load filename.mat
Output = table(t_out, M1_out, M2_out, M3_out, M4_out);
Output(:,:);
filename = 'filename_outputs.xlsx';
writetable(Output,filename)

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Historical Contests에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2023년 1월 3일

댓글:

2023년 1월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by