How to reset typing in loop input?

1 Ansicht (letzte 30 Tage)
Emilia
Emilia am 13 Dez. 2020
Beantwortet: Subhadeep Koley am 13 Dez. 2020
Hello,
I want to make a typo refund if there is a user error. For example if a user types a zero or empty matrix then the output will return the same as original.
How to do it if there is an exception to "error", by typing ctrl+c.
Thanks for the helpers
clc;
clear;
sigma=input('Insert normal stresses[Mpa] and shear stresses[Mpa] of the cauchy stress tensor:');
if sigma==[] || sigma==[0 0 0;0 0 0;0 0 0]
error('The stress tensor does not exist. Please re type in the request');
end

Akzeptierte Antwort

Subhadeep Koley
Subhadeep Koley am 13 Dez. 2020
sigma = input('Insert normal stresses[Mpa] and shear stresses[Mpa] of the cauchy stress tensor:');
if isempty(sigma) || ~all(sigma(:))
error('The stress tensor does not exist. Please re type in the request');
end

Weitere Antworten (0)

Kategorien

Mehr zu Stress and Strain finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by