Home » Blog » Write a MATLAB program to evaluate the function:

Write a MATLAB program to evaluate the function:

y(x)=ln 1/(1 –x)

for any user-specified value of x, where x is a number <1.0 (note that ln is the natural logarithm, the logarithm to the base e). Use an if structure to verify that the value passed to the program is legal. If the value of x is legal, calculate y(x). If not, write a suitable error message and quit.

clc;
clear all;
close all;
 
x = input('Enter Value For X ');
 
if x >= 1.0
    disp('Illegal Value For X!!');
    return
end
 
yx = log(1/(1-x));
disp(['y(x) = ',num2str(yx)]);

Leave a Reply

Your email address will not be published.