Info
此问题已关闭。 请重新打开它进行编辑或回答。
Why is there a syntax error for my code?
1 次查看(过去 30 天)
显示 更早的评论
>> %% User Input
>> phi1=input('Please input the first boundary condition');
Please input the first boundary conditionphi2=input('Please input the second boundary condition');
Please input the second boundary conditionL=input('What''s the length of the domain?');
What's the length of the domain?rho=input('What''s the density of the fluid?');
What's the density of the fluid?K=input('What''s the co-efficient of diffusion?');
What's the co-efficient of diffusion?u=input('What''s the flow velocity?');
What's the flow velocity?nx=input('What''s the number of grid points');
What's the number of grid pointsfprintf('Menu\n1)Central Differencing\n2)Upwind Differencing\n3)Hybr
id Differencing\n4)Power Law\n5)Exit\n\n');
Menu
1)Central Differencing
2)Upwind Differencing
3)Hybrid Differencing
4)Power Law
5)Exit
>> Choice=input('Please input the serial number of the process');
Please input the serial number of the processif Choice==1
parse error:
syntax error
0 个评论
回答(1 个)
per isakson
2020-4-5
I don't think the problem is with your code, but rather with the users input. input( 'Please input ... ' ) expects an expression (see help on input). ==1 isn't a legal expression. It's when Matlab tries to evaluate ==1 that the error is thrown. A trailing space after the text makes it more readable.
>> Choice=input('Please input the serial number of the process: ');
Please input the serial number of the process: ==1
Error: Invalid use of operator.
>> Choice=input('Please input the serial number of the process: ');
Please input the serial number of the process: 1
>> Choice
Choice =
1
>>
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!