Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Variables accessible in unrelated files?

1 回表示 (過去 30 日間)
Amory Tillinghast-Raby
Amory Tillinghast-Raby 2020 年 1 月 5 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Currently, on my computer, I have two Matlab files. One is saved to my desktop and one is saved to my documents folder. I see no reason why these two .m files should be able to access one another. Here is the code for the first .m file which is saved to my documents folder.
syms R
rstatic = .5;
comp = .5;
targetVolume = (4/3)*(pi)*(.5)^3;
startingCircumfrence = 2*pi*(.5);
%Preliminary Equations
d = rstatic + (R - comp);
a = (1/d)*((4*(d^2)*(R^2))-((d^2)-(rstatic^2)+(R^2))^2)^(1/2);
z = ((rstatic^2) - (((1/2)*a)^2))^(1/2);
capHeight1 = (rstatic - z);
capHeight2 = (comp - capHeight1);
capVol1 = ((pi*(capHeight1)^2)/3)*((3*rstatic)-capHeight1);
capVol2 = ((pi*(capHeight2)^2)/3)*((3*R)-capHeight2);
removedVolume = (capVol1 + capVol2);
%Volume Expansion
deformedVol = ((4/3)*(pi)*(R^3)) - removedVolume == targetVolume;
radiusFromExpansion = vpasolve(deformedVol,R,[.5 Inf]);
circumfrenceFromExpansion = (2*pi*radiusFromExpansion);
%Return the values
radiusFromExpansion %#ok<NOPTS>
circumfrenceFromExpansion %#ok<NOPTS>
Somehow, in the .m file that is saved to my desktop, I am able to call circumfrenceFromExpansion. The entirity of the desktop file is
circumfrenceFromExpansion
Can someone explain to me how this is possible and what I can do to prevent this? The two projects are unrelated and ideally I would like to reuse variable names.

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by