我的 if 语句没有做我需要它做的事情
因此,对于我的数值方法模块,我们要求使用数值方法解决现实世界问题,并通过八度编写脚本,我是我项目的最后一部分,但是它只是不想像我打算这样做一样做?有人可以在这里帮我吗?
代码部分如下: 有争议的代码
F=1;
M=3;
input('has this met your criterion? (F/M): ')
if (F)
printf('\n'); %Spacer
printf('__________________________________________________ \n');%Divider
printf('\n'); %Spacer
printf('summation of results are as follows:');
printf('\n'); %Spacer
printf('___________________________________________\n');%Divider
printf('\n'); %Spacer
printf(__________________________________________\n');%Divider
printf('\n'); %Spacer
printf('flows (m3/s)');
QinPipe1=Q1x2=Di(1,1);
QinPipe2=Q2x2=Di(2,1);
QinPipe3=Q3x2=Di(3,1);
printf('\n'); %Spacer
printf('\n'); %Spacer
QinPipe1=Q1x2
QinPipe2=Q2x2
QinPipe3=Q3x2
printf("______________________________________\n");
printf("criterion check(percentage):\n");
printf('\n'); %Spacer
printf('\n'); %Spacer
RelError1=Q1e1=abs(((abs(Q1x)-abs(Q1x2))/abs((Q1x2))))*100;
RelError2=Q2e2=abs(((abs(Q2x)-abs(Q2x2))/abs((Q2x2))))*100;
RelError3=Q3e3=abs(((abs(Q3x)-abs(Q3x2))/abs((Q3x2))))*100;
RelError1=Q1e1
RelError2=Q2e2
RelError3=Q3e3
else if (M)
cramerwdntest
end
endif
我需要做的是,它在运行先前的命令直到运行之前启动这一点一旦用户用f或m回答,它应该打印出脚本运行的最终结果的总和(f),如果没有,则应再次运行以下m文件(m),直到用户最终回答用户回答(f)无论您输入什么字母(m或f),它运行在if语句的第一部分,无论
我试图使用“ yes_or_no”功能,但这似乎不起作用,这两个
都可以帮助我。
so for my Numerical methods module we are requested solving a real world problem using Numerical methods and write a script for it through octave I am the last part of my project but it just doesn't want to do as I intend it to do? can someone perhaps help me here?
The section of code is as follows:
Code in question
F=1;
M=3;
input('has this met your criterion? (F/M): ')
if (F)
printf('\n'); %Spacer
printf('__________________________________________________ \n');%Divider
printf('\n'); %Spacer
printf('summation of results are as follows:');
printf('\n'); %Spacer
printf('___________________________________________\n');%Divider
printf('\n'); %Spacer
printf(__________________________________________\n');%Divider
printf('\n'); %Spacer
printf('flows (m3/s)');
QinPipe1=Q1x2=Di(1,1);
QinPipe2=Q2x2=Di(2,1);
QinPipe3=Q3x2=Di(3,1);
printf('\n'); %Spacer
printf('\n'); %Spacer
QinPipe1=Q1x2
QinPipe2=Q2x2
QinPipe3=Q3x2
printf("______________________________________\n");
printf("criterion check(percentage):\n");
printf('\n'); %Spacer
printf('\n'); %Spacer
RelError1=Q1e1=abs(((abs(Q1x)-abs(Q1x2))/abs((Q1x2))))*100;
RelError2=Q2e2=abs(((abs(Q2x)-abs(Q2x2))/abs((Q2x2))))*100;
RelError3=Q3e3=abs(((abs(Q3x)-abs(Q3x2))/abs((Q3x2))))*100;
RelError1=Q1e1
RelError2=Q2e2
RelError3=Q3e3
else if (M)
cramerwdntest
end
endif
What I need it to do is that after it has run the previous commands up until this point once the user answers with either F or M it should either print out the summation (F) of the final results from the script run earlier and if not it should run the following m file (M) again until the user eventually answers with an (F) instead no matter what letter you enter (M or F) it runs the first part of the if statement regardless
I attempted to use the "yes_or_no" function but that seemed to not work either
Could someone please help me on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
F和M表示什么,为什么将它们设置为1和3?
这里有很多要改进的地方,但是要回答您的问题:
's'
用于指定输入字符串(字符)。您必须将输入存储在变量中。我在中称其为,但是您应该选择一个在脚本中与其目的匹配的变量名称。
您必须将输入与字符
f
,或输入一个数字而不是字符串进行比较。新答案:
What do F and M represent, and why do you set them to 1 and 3?
There's a lot to improve here, but to answer your question:
's'
is used to specify that you input a string (character). You must store the input in a variable. I've called itin
but you should choose a variable name that matches its purpose in your script.You must compare the input to the character
F
, or input a number instead of a string.New answer: