use parentheses. Otherwise, check for mismatched delimiters.

100 次查看(过去 30 天)
i want to create gui caculator above is my coding
N1=get(handles.N1,'string');
N2=get(handles.N2,'string');
s1=get(handles.s1,'string');
s2=get(handles.s2,'string');
slope1=get(handles.slope1,'string');
slope2=get(handles.slope2,'string');
vm=get(handles.vm,'string');
k=(str2num(N1)/str2num(N2)*str2num(s1)/str2num(s2)*str2num(slope1)/str2num(slope2)^(1/3);
alpha=(k*str2num(s2)-str2num(s1)/((k-1)*vm);
set(handles.coefficient,'string',num2str(alpha));
but command window said Error: File: untitled3.m Line: 298
k=(str2num(N1)/str2num(N2)*str2num(s1)/str2num(s2)*str2num(slope1)/str2num(slope2)^(1/3);
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
what i should do thanks

采纳的回答

Arif Hoq
Arif Hoq 2023-1-30
use the parentheses at the end of syntax.
k=(str2num(N1)/str2num(N2)*str2num(s1)/str2num(s2)*str2num(slope1)/str2num(slope2)^(1/3));
  3 个评论
Steven Lord
Steven Lord 2023-1-30
Let's count parentheses. Start with a count of 0. Every time you see ( add 1 to the count. Every time you see ) subtract 1. If you don't get back to 0 by the end of the line or if you ever get to -1 you have mismatched parentheses.
alpha=(k*str2num(s2)-str2num(s1)/((k-1)*vm);
% 0 1 2 1 2 1 23 2 1
You have one more ( than you do ). Where to add the missing ) depends on what you're trying to do.
alpha=(k*str2num(s2)-str2num(s1))/((k-1)*vm);
% 0 1 2 1 2 10 12 1 0
alpha=(k*str2num(s2)-str2num(s1)/((k-1)*vm));
% 0 1 2 1 2 1 23 2 10
alpha=(k*str2num(s2))-str2num(s1)/((k-1)*vm);
% 0 1 2 10 1 0 12 1 0

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by