No results from calculations in the command window
12 次查看(过去 30 天)
显示 更早的评论
Hi there,
For some reason I am not getting any output results in the command window. I click on run and no results appear in the command window from my script. Nor, is there any results in the workspace - even though there a lots of calculations. I have restarted my computer and still there is no change. The last thing I was doing was trying to create a MATLAB function. Also, in the editor tab the option to create a new scipt is faded out. So I can't access a new script. I have been using MATLAB online for months and I have never experienced this problem or any problem like it.
I am very confused and I do not know what is going wrong!
I hope someone can help?
Many thanks,
Scott
采纳的回答
Star Strider
2025-7-22
I am not certain that I fully understasnd your problem.
MATLAB functions have their own workspaces, so variables local to the function will not appear in the workspace window.
I am not certain what you are doing, however be sure to actually call the function (with all appropriate arguments), and return as many outputs as the function produces, at least to troubleshoot this.
13 个评论
Scott Banks
2025-7-22
Hi Star Strider,
What I am saying is that I click on Run and no results appear in the command window from my script. The command window is just blank - no results from the script are appearing!
Star Strider
2025-7-22
Does this work if you run it in the Command Window:
>> a = 1; b = 2; a + b
Running it here produces --
a = 1; b = 3; a + b
ans = 4
In MATLAB Online, entering that line at the prompt and then hitting 'ENTER' produces the same result.
.
Scott Banks
2025-7-22
I just came back to MATLAB after a couple of hours break, and everything was working again until I tried to run my saved function. After trying to run my function its gone back to nothing apearing in the command window.
Yes, even running simple commands in the command window is not working, Star Strider.
Star Strider
2025-7-22
I'm a bit confused at this point.
What OS are you using and what version of MATLAB?
Does your code only work in MATLAB Online and not in your offline (personal computer) MATLAB installation? (MATLAB Online is currently R2024b Update 5. I just now checked.)
if so, uninstalling and reinstalling MATLAB may be yoiur only option.
Scott Banks
2025-7-22
I think I have found the problem:
In my function I have an option to select certain data. Here is the complete file.
function [Inflex] = inflection_point
Inflex01 = [-0.35;-0.10;0.10;0.30;0.50;0.75;1.20];
Inflex02 = [-0.50;0.15;0.25;0.35;0.45;0.60;0.95];
Inflex03 = [0.10;0.25;0.30;0.40;0.45;0.55;0.85];
Inflex04 = [0.20;0.30;0.35;0.40;0.45;0.50;0.80];
Inflex05 = [0.20;0.35;0.40;0.40;0.45;0.50;0.75];
Inflex06 = [0.25;0.35;0.40;0.45;0.45;0.50;0.70];
Inflex07 = [0.30;0.35;0.40;0.45;0.45;0.50;0.70];
Inflex08 = [0.30;0.40;0.45;0.45;0.45;0.50;0.65];
Inflex09 = [0.35;0.40;0.40;0.45;0.45;0.50;0.65];
Inflex1 = [0.35;0.40;0.40;0.45;0.45;0.50;0.65];
Inflex2 = [0.40;0.45;0.45;0.50;0.50;0.50;0.55];
Inflex3 = [0.45;0.45;0.45;0.50;0.50;0.50;0.55];
Inflex4 = [0.40;0.50;0.50;0.50;0.50;0.50;0.55];
Inflex5 = [0.40;0.50;0.50;0.50;0.50;0.50;0.55];
Storey = ['7';'6';'5';'4';'3';'2';'1'];
Khat01 = [Inflex01];
Khat02 = [Inflex02];
Khat03 = [Inflex03];
Khat04 = [Inflex04];
Khat05 = [Inflex05];
Khat06 = [Inflex06];
Khat07 = [Inflex07];
Khat08 = [Inflex08];
Khat09 = [Inflex09];
Khat1 = [Inflex1];
Khat2 = [Inflex2];
Khat3 = [Inflex3];
Khat4 = [Inflex4];
Khat5 = [Inflex5];
Tb = table(Storey,Khat01,Khat02,Khat03,Khat04,Khat05,Khat06,Khat07,Khat08,Khat09,Khat1,Khat2,Khat3,Khat4,Khat5)
Khat = input('Enter a value of Khat: ')
switch Khat
case (Khat >= 0) && (Khat <= 0.14)
disp(Tb(:,2))
case 0.2
disp(Tb(:,3))
case 0.3
disp(Tb(:,4))
case 0.4
disp(Tb(:,5))
case 0.5
disp(Tb(:,6))
case 0.6
disp(Tb(:,7))
case 0.7
disp(Tb(:,8))
case 0.8
disp(Tb(:,9))
case 0.9
disp(Tb(:,10))
case 1
disp(Tb(:,11))
case 2
disp(Tb(:,12))
case 3
disp(Tb(:,13))
case 4
disp(Tb(:,14))
case 5
disp(Tb(:,15))
end
end
Now, when I am in a different file and run this the command window like I said goes blank. However, if I enter say 0.8 in the command window I get the correct display.
Which is great!!!
The only annoying thing is that I don't get the message "Enter a value of Khat", like I do in the file for the inflection_point itself. The command window is empty with no prompt to input a value of Khat. Do you know why this is?
Star Strider
2025-7-22
编辑:Star Strider
2025-7-22
When I put your function in a script file that includes the command:
inflection_point
regardless of the number I supply in response to the prompt (that always shows up), I get:
Output argument "Inflex" (and possibly others) not assigned a value in the execution ...
You need to assign a value to 'Inflex' at an appropriate point in your code.
I'm not certain what your function actually is supposed to do, however using the ismember (or ismembertol) function or one of the interpolation functions might be appropriate in order to asssign a value to 'Inflex'. I can probably help with that if I know what you actually want to do.
The code I'm using (in its entirety) is:
% % % Scott_Banks_2025_07_22.m
Infles = inflection_point
function [Inflex] = inflection_point
Inflex01 = [-0.35;-0.10;0.10;0.30;0.50;0.75;1.20];
Inflex02 = [-0.50;0.15;0.25;0.35;0.45;0.60;0.95];
Inflex03 = [0.10;0.25;0.30;0.40;0.45;0.55;0.85];
Inflex04 = [0.20;0.30;0.35;0.40;0.45;0.50;0.80];
Inflex05 = [0.20;0.35;0.40;0.40;0.45;0.50;0.75];
Inflex06 = [0.25;0.35;0.40;0.45;0.45;0.50;0.70];
Inflex07 = [0.30;0.35;0.40;0.45;0.45;0.50;0.70];
Inflex08 = [0.30;0.40;0.45;0.45;0.45;0.50;0.65];
Inflex09 = [0.35;0.40;0.40;0.45;0.45;0.50;0.65];
Inflex1 = [0.35;0.40;0.40;0.45;0.45;0.50;0.65];
Inflex2 = [0.40;0.45;0.45;0.50;0.50;0.50;0.55];
Inflex3 = [0.45;0.45;0.45;0.50;0.50;0.50;0.55];
Inflex4 = [0.40;0.50;0.50;0.50;0.50;0.50;0.55];
Inflex5 = [0.40;0.50;0.50;0.50;0.50;0.50;0.55];
Storey = ['7';'6';'5';'4';'3';'2';'1'];
Khat01 = [Inflex01];
Khat02 = [Inflex02];
Khat03 = [Inflex03];
Khat04 = [Inflex04];
Khat05 = [Inflex05];
Khat06 = [Inflex06];
Khat07 = [Inflex07];
Khat08 = [Inflex08];
Khat09 = [Inflex09];
Khat1 = [Inflex1];
Khat2 = [Inflex2];
Khat3 = [Inflex3];
Khat4 = [Inflex4];
Khat5 = [Inflex5];
Tb = table(Storey,Khat01,Khat02,Khat03,Khat04,Khat05,Khat06,Khat07,Khat08,Khat09,Khat1,Khat2,Khat3,Khat4,Khat5)
Khat = input('Enter a value of Khat: ')
switch Khat
case (Khat >= 0) && (Khat <= 0.14)
disp(Tb(:,2))
case 0.2
disp(Tb(:,3))
case 0.3
disp(Tb(:,4))
case 0.4
disp(Tb(:,5))
case 0.5
disp(Tb(:,6))
case 0.6
disp(Tb(:,7))
case 0.7
disp(Tb(:,8))
case 0.8
disp(Tb(:,9))
case 0.9
disp(Tb(:,10))
case 1
disp(Tb(:,11))
case 2
disp(Tb(:,12))
case 3
disp(Tb(:,13))
case 4
disp(Tb(:,14))
case 5
disp(Tb(:,15))
end
end
% ========================================================================
.
EDIT -- Corrected typographical errors.
.
Star Strider
2025-7-22
Considering Help with Inequalities In Switch Statement are you still interested in pursuing this here?
I offered to help with respect to using various functions, depending on what you want to do (that I'm still not certain about). You could use any of several functions to determine what values(s) 'Inflex' is everntually assigned.
.
Scott Banks
2025-7-22
Thanks, Star Strider. I have now assigned a value to Inflex and all seems to be good now.
It quite long winded what I want to do, but I want to be able to extract any inflection point that is contained in the Table Tb and apply it to any column in a storey within a tall building (there's a much bigger picture here). Note: an inflection point in structural engineering is a point where the bending moment equals zero in the member.
Khat is a parameter that takes the mean stiffness of beams relative to the column stiffness. If Khat equals 0.6 for example, then the coresponding inflection points are found in the 7th column in the table Tb - for each of the 7 storeys. Thus, if I want to work on the 7th storey with Khat equaling 0.6, the percentage distance for the inflection point from the bottom of the storey is 25% (0.25 in the table). So you multiply the length of the column by 0.25, there you have the zero point bending moment.
Thus, again, I want to be able to extract any value from the table when I need to. There is still some way to go, so I will likely be asking for more help!
Star Strider
2025-7-22
编辑:Star Strider
2025-7-22
My pleasure.
I'm not certain what the variables in the table represent.
Do you want to interpolate between them to get a single value or interpolated vector for 'Inflex', or do you want to get the closest column to a specific value for 'Khat' to assign to 'Inflex'?
Here's an example of an interpolation approach --
Inflex = inflection_point
Tb = 7×15 table
Storey Khat01 Khat02 Khat03 Khat04 Khat05 Khat06 Khat07 Khat08 Khat09 Khat1 Khat2 Khat3 Khat4 Khat5
______ ______ ______ ______ ______ ______ ______ ______ ______ ______ _____ _____ _____ _____ _____
7 -0.35 -0.5 0.1 0.2 0.2 0.25 0.3 0.3 0.35 0.35 0.4 0.45 0.4 0.4
6 -0.1 0.15 0.25 0.3 0.35 0.35 0.35 0.4 0.4 0.4 0.45 0.45 0.5 0.5
5 0.1 0.25 0.3 0.35 0.4 0.4 0.4 0.45 0.4 0.4 0.45 0.45 0.5 0.5
4 0.3 0.35 0.4 0.4 0.4 0.45 0.45 0.45 0.45 0.45 0.5 0.5 0.5 0.5
3 0.5 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.5 0.5 0.5 0.5
2 0.75 0.6 0.55 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5
1 1.2 0.95 0.85 0.8 0.75 0.7 0.7 0.65 0.65 0.65 0.55 0.55 0.55 0.55
Khat = 0.4200
Inflex = 7×2 table
Storey Interpolated Value for Khat = 0.4200
______ ____________________________________
7 0.2
6 0.31
5 0.36
4 0.4
3 0.45
2 0.5
1 0.79
function [Inflex] = inflection_point
Inflex01 = [-0.35;-0.10;0.10;0.30;0.50;0.75;1.20];
Inflex02 = [-0.50;0.15;0.25;0.35;0.45;0.60;0.95];
Inflex03 = [0.10;0.25;0.30;0.40;0.45;0.55;0.85];
Inflex04 = [0.20;0.30;0.35;0.40;0.45;0.50;0.80];
Inflex05 = [0.20;0.35;0.40;0.40;0.45;0.50;0.75];
Inflex06 = [0.25;0.35;0.40;0.45;0.45;0.50;0.70];
Inflex07 = [0.30;0.35;0.40;0.45;0.45;0.50;0.70];
Inflex08 = [0.30;0.40;0.45;0.45;0.45;0.50;0.65];
Inflex09 = [0.35;0.40;0.40;0.45;0.45;0.50;0.65];
Inflex1 = [0.35;0.40;0.40;0.45;0.45;0.50;0.65];
Inflex2 = [0.40;0.45;0.45;0.50;0.50;0.50;0.55];
Inflex3 = [0.45;0.45;0.45;0.50;0.50;0.50;0.55];
Inflex4 = [0.40;0.50;0.50;0.50;0.50;0.50;0.55];
Inflex5 = [0.40;0.50;0.50;0.50;0.50;0.50;0.55];
Storey = ['7';'6';'5';'4';'3';'2';'1'];
Khat01 = [Inflex01];
Khat02 = [Inflex02];
Khat03 = [Inflex03];
Khat04 = [Inflex04];
Khat05 = [Inflex05];
Khat06 = [Inflex06];
Khat07 = [Inflex07];
Khat08 = [Inflex08];
Khat09 = [Inflex09];
Khat1 = [Inflex1];
Khat2 = [Inflex2];
Khat3 = [Inflex3];
Khat4 = [Inflex4];
Khat5 = [Inflex5];
Tb = table(Storey,Khat01,Khat02,Khat03,Khat04,Khat05,Khat06,Khat07,Khat08,Khat09,Khat1,Khat2,Khat3,Khat4,Khat5)
% Khat = input('Enter a value of Khat: ')
Khat = 0.42
Tba = [Tb{:,2} table2array(Tb(:,2:end))];
ival = [0 0.14 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 2 3 4 5];
inflx = interp1(ival.', Tba.', Khat);
Inflex = table(Storey,inflx(:), VariableNames={'Storey',sprintf('Interpolated Value for Khat = %.4f',Khat)});
% switch Khat
% case (Khat >= 0) && (Khat <= 0.14)
% disp(Tb(:,2))
% case 0.2
% disp(Tb(:,3))
% case 0.3
% disp(Tb(:,4))
% case 0.4
% disp(Tb(:,5))
% case 0.5
% disp(Tb(:,6))
% case 0.6
% disp(Tb(:,7))
% case 0.7
% disp(Tb(:,8))
% case 0.8
% disp(Tb(:,9))
% case 0.9
% disp(Tb(:,10))
% case 1
% disp(Tb(:,11))
% case 2
% disp(Tb(:,12))
% case 3
% disp(Tb(:,13))
% case 4
% disp(Tb(:,14))
% case 5
% disp(Tb(:,15))
% end
end
The online 'Run' facility doesn't permit any interactivity, so I defined 'Khat' internally here.
EDIT -- (22 Jul 2025 at 21:37)
Added 'interpolation approach'.
.
Scott Banks
2025-7-22
That's brilliant, Star Strider. I was just going to go for the closet column for a single value, If I would have used interpolation I would have probably tried to incorporate the formula - y = y1 + (x - x1)/(x2 - x1)*(y2 - y1). Which would have had much more code. Great one!
Star Strider
2025-7-22
编辑:Star Strider
2025-7-23
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
EDIT -- (23 Jul 2025 at 00:55)
Note that there are also stepwise interpolation methods available, notably 'previous', 'next', and 'nearest'.
.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
