How to define points at specific values

8 Ansichten (letzte 30 Tage)
Anthony Koning
Anthony Koning am 13 Dez. 2021
Beantwortet: Image Analyst am 13 Dez. 2021
Does anyone know how to define a value at a specific point for similarly to using L'Hopital's rule. The current code I have will not register values this way, and this was how our professor told us to define these values.
v = -50:10:50
if (v>=49.9 & v<=50.1)
x = .01
else x = (.01(v-50))/(exp(.1(v-50))-1)
end

Antworten (1)

Image Analyst
Image Analyst am 13 Dez. 2021
Some syntax errors there in your code. Try this
v = -50:10:50
% Initialize x for outside the range.
x = 0.01 * ones(size(v));
indexesInRange = (v >= 49.9) & (v <= 50.1) % Only the last element, 50, will be in range.
% Assign a formula to x at those places where v is in range.
x(indexesInRange) = (.01 * (v(indexesInRange)-50)) ./ (exp(0.1 * (v(indexesInRange)-50)) - 1)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by