use parentheses. Otherwise, check for mismatched delimiters.
147 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Arif Hoq
on 30 Jan 2023
use the parentheses at the end of syntax.
k=(str2num(N1)/str2num(N2)*str2num(s1)/str2num(s2)*str2num(slope1)/str2num(slope2)^(1/3));
3 Comments
Steven Lord
on 30 Jan 2023
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
More Answers (0)
See Also
Categories
Find more on Variables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!