One condition is not being fulfilled, and suddenly when i wrote on command window, give me a infinite menu, and i can not close it
2 ビュー (過去 30 日間)
表示 古いコメント
Hello, in this program that I'm building, when b1==2, there is no fulfillment of that condition, and when I write in the window command, later an infinite menu appears... I don't understand why, I've tried everything and I don't understand because my idea is not working.
So the problem begins when the user chose: 'Manually'
If u respond on input 'a1' : 2, it´s not giving what it´s in the code, it gives me the condition b1==1, and appears the menu that i talked earlier.
please help, the code it´s:
clc, clear, close
while true
a=menu({'This program allows the fitting of functions to experimental points.', ...
'To start the program, click on the Start button.'},'Start','Exit');
%Operation of menu a
if a==1
b= menu('How do you intend to insert the experimental points?', ...
'By a file','Manually','Back','Exit');
end
if a==2
break
end
%Operation of the menu b
if b==1
elseif b==2
a1= sprintf('If you want to advance in the program, press 1.\n If you want to go back to the previous menu, press 2: ');
b1= input(a1);
p = input('How many experimental values do you want to insert?: ');
if b1==1
while p < 2 && p <= 0
errordlg ({'The number of experimental points must be at least 2.','Please press Ok and enter the desired value in the Command Window.'})
p = input('How many experimental values do you want to insert?: ');
end
n = p/2; %Number of matrix rows
m = 2; %Number of matrix columns
a = zeros(n,m); %prelocation
for i=1:n
for j=1:m
if (j == 1)
fprintf('Enter the %0.0fᵒ ',i)
a(i,j)= input('value of x: ');
else
fprintf('Enter the %0.0fᵒ ',i)
a(i,j)= input('value of y: ');
end
end
end
a=reshape(a,n,m); %Matrix according to the number of rows and columns
disp(a); %Matrix according to the number of rows and columns
end
if b1==2
clc
b= menu('How do you intend to insert the experimental points?', ...
'By a file','Manually','Back','Exit');
else
disp('The number entered was not correct')
end
if b==3
a=menu({'This program allows the fitting of functions to experimental points.', ...
'To start the program, click on the Start button.'},'Start','Exit');
if b==4
break
end
end
end
end
採用された回答
VBBV
2023 年 1 月 13 日
編集済み: VBBV
2023 年 1 月 13 日
clc, clear, close
while true
a=menu({'This program allows the fitting of functions to experimental points.', ...
'To start the program, click on the Start button.'},'Start','Exit');
%Operation of menu a
if a==1
b= menu('How do you intend to insert the experimental points?', ...
'By a file','Manually','Back','Exit');
end
if a==2
break
end
%Operation of the menu b
if b==1
disp('Insert a file')
elseif b==2
a1 = input('If you want to advance in the program, press 1.\n If you want to go back to the previous menu, press 2: ');
b1 = a1 ;
if b1==1
p = input('How many experimental values do you want to insert?: '); % this statement
while p < 2 && p <= 0
errordlg ({'The number of experimental points must be at least 2.','Please press Ok and enter the desired value in the Command Window.'})
p = input('How many experimental values do you want to insert?: ');
end
n = p/2; %Number of matrix rows
m = 2; %Number of matrix columns
a = zeros(n,m); %prelocation
for i=1:n
for j=1:m
if (j == 1)
fprintf('Enter the %0.0fᵒ ',i)
a(i,j)= input('value of x: ');
else
fprintf('Enter the %0.0fᵒ ',i)
a(i,j)= input('value of y: ');
end
end
end
a=reshape(a,n,m); %Matrix according to the number of rows and columns
disp(a); %Matrix according to the number of rows and columns
elseif b1==2
clear b
b = menu('How do you intend to insert the experimental points?', ...
'By a file','Manually','Back','Exit');
else
disp('The number entered was not correct')
end
elseif b==3
a=menu({'This program allows the fitting of functions to experimental points.', ...
'To start the program, click on the Start button.'},'Start','Exit');
elseif b==4
break
end
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!