필터 지우기
필터 지우기

redo part if script if not happy with the outcome

조회 수: 3 (최근 30일)
Lotte Piek
Lotte Piek 2023년 2월 24일
댓글: Lotte Piek 2023년 2월 27일
Hi everyone,
I am doing some data filtering and made a script for it. I am now looking for a way to sort of say 'yes' to the outcome of the script if the outcome is good or redo the script if I the outcome is not good (maybe by using the input() function). Anybody has done this before and can help me out?
  댓글 수: 2
Dyuman Joshi
Dyuman Joshi 2023년 2월 24일
It is difficult to give a clear answer as we don't know what you are trying to do. Please post relevant code and data, and ask/mention specifically what you want to do.
Rik
Rik 2023년 2월 24일
I would strongly advise you to consider functions for anything non-trivial. Functions provide a stable interface that allow you to document the purpose along with expected inputs and outputs. That allows modular programming so you can reuse functions later without having to rewrite everything from scratch or copy-pasting code sections until they work.

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

채택된 답변

Ashu
Ashu 2023년 2월 24일
I understand that you want to make decisions in your code based on the output from a script. A general approach to achieve this is as follows:
% execute the data filtering script
outcome = data_filtering_script();
% User response
response = input('Was the outcome good? Enter ''yes'' or ''no'': ', 's');
% Make a decision on re-running the script.
if strcmpi(response, 'yes')
disp('You can proceed with the next steps.');
elseif strcmpi(response, 'no')
disp('Redo the script.');
% Call the script again
outcome = data_filtering_script();
else
disp('Invalid input.');
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by