What could be the solution of this error (Parse error ar'(':usage might be invalid MATLAB syntax)?
이전 댓글 표시
I have the following error that is appearing in my work in %time domain
%time domain
1-tmin=0;
2-tmax=200;
3-dt1= ((2*D)/(U^2))-(deltax/U);
4-deltat=0.8*min([0.1,dt1]);
5-if deltat<0.01
6-deltat=0.01;
end
Line 6 deltat = 0.01;
the error is (Parse error ar'(':usage might be invalid MATLAB syntax).
댓글 수: 3
DGM
2024년 4월 30일
This doesn't make sense. There's seems to be some code that's either missing or incomplete (since there are lots of undefined variables). Are those line numbers literally in the file as code? Regardless of whether they are, they're not on the right lines. The error message describes a syntax error which is clearly not even present on the line described.
Paste or attach the actual code and/or error message, not a reinterpretation of it.
Manikanta Aditya
2024년 4월 30일
편집: Manikanta Aditya
2024년 4월 30일
I feel, D, U and deltax are to be defined, rest part code is fine. Yeah those 1-, 2- are line numbers xD
Stephen23
2024년 4월 30일
"Yeah those 1-, 2- are line numbers xD"
Get rid them.
답변 (2개)
Manikanta Aditya
2024년 4월 30일
편집: Manikanta Aditya
2024년 4월 30일
The error message you’re seeing is typically due to a syntax error in your MATLAB code. In your case, the error message is “Parse error at ‘(’: usage might be invalid MATLAB syntax”. This suggests that there might be an issue with the use of parentheses in your code.
Check this code:
D = 1;
U = 1;
deltax = 1;
tmin=0;
tmax=200;
dt1= ((2*D)/(U^2))-(deltax/U);
deltat=0.8*min([0.1,dt1]);
if deltat<0.01
deltat=0.01;
end
Hope this helps.
댓글 수: 5
Abdallah Alrefaie
2024년 4월 30일
DGM
2024년 4월 30일
"it didn't work" tells us nothing meaningful.
What is the actual code you are trying to run?
What is the actual error message that you get?
Manikanta Aditya
2024년 5월 1일
편집: Manikanta Aditya
2024년 5월 1일
@Abdallah Alrefaie, I ran the same code I mentioned above in my MATLAB R2024a, and I was able to get the correct outputs. as mentioned by @DGM if you have any errors share them here.
Abdallah Alrefaie
2024년 5월 3일
Manikanta Aditya
2024년 5월 5일
Welcome @Abdallah Alrefaie
combinations=n choosek(elements,k);
disp('Combinations:');
disp(combinations);
댓글 수: 1
Walter Roberson
2026년 4월 1일 8:29
As you can see, that code has a syntax error, at the space between the n and the choosek
카테고리
도움말 센터 및 File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!