use parentheses. Otherwise, check for mismatched delimiters.

조회 수: 101 (최근 30일)
BOZHENG
BOZHENG 2023년 1월 30일
댓글: Steven Lord 2023년 1월 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
Arif Hoq
Arif Hoq 2023년 1월 30일
alpha=(k*str2num(s2)-str2num(s1))/((k-1)*vm);
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