My code is not working or MATLAB is not responding?

조회 수: 32 (최근 30일)
Josef Laura
Josef Laura 2024년 5월 8일
댓글: Josef Laura 2024년 5월 8일
I'm currently working on designing a dynamic interface, which necessitates taking a cell array input from the user.
I've encountered an unexpected behavior while attempting this in MATLAB. Instead of storing the cell array in the workspace, the input statement appears multiple times in the command window.
Even when providing a normal numeric array like 1 2 3 4 5, it fails to work as expected. surprisingly, there are no visible warnings or errors, leaving me uncertain whether there's an issue with my code or if MATLAB itself is hanging.
Looking forward for assistance in resolving this issue
  댓글 수: 3
Josef Laura
Josef Laura 2024년 5월 8일
편집: Josef Laura 2024년 5월 8일
My code is nearly 1200 lines but the execution is being stopped here
prompt = "Please enter your Name, ID , Age : "; Details = input(prompt);
Josef Laura
Josef Laura 2024년 5월 8일
편집: Josef Laura 2024년 5월 8일

This is my command window

댓글을 달려면 로그인하십시오.

채택된 답변

Pavan Sahith
Pavan Sahith 2024년 5월 8일
편집: Pavan Sahith 2024년 5월 8일
It seems you're encountering an issue while collecting user input through MATLAB.
If you're seeing only the prompt “Please enter your Name, ID , Age :“in the command window and the execution appears to pause there, the problem likely lies in how you're providing input to the ' input ' function.
When prompted with “Please enter your Name, ID , Age :“, ensure you input the array in a format that MATLAB can interpret. This means enclosing elements within square brackets [ ] and separating them with commas or spaces.
If you're aiming to gather heterogeneous data from the user, the input should be in the form of a cell array, meaning the user should encapsulate their input within curly braces, like so:
{'james' 'S34R21' 43}
Additionally, if you're testing your code with numeric arrays, make sure to enclose the elements within square brackets [ ] and separate them with commas or spaces, like this:
[1 2 3 4 5]
You can refer to following MathWorks documentation to know more about ' input '
I hope this will help you resolving the issue.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by