Hello, I am really new to Scilab and have been forced to use it for one and only one university question to graph a two functions I can graph the first function but when I try to add the second I enter something wrong. Could someone take a look at my .sce file and help point me in the right direction? clear, clf // Define your variables t1 =[0:0.01:100]; y1=25+75 ./(1+exp((t1-50)/10)); t2=[0:0.01:100]; y2 = -10 log((75/t2-25) . -1) + 50; // Use the logflag option to define logarithmic or normal axis // n for normal, l for logarithmic. plot(t1,y1,t2,y2). // Use xgrid to add a grid on your current figure xgrid; thanks Dan

Scilab Not Spam

__Answers:__

I've modified your code-

clear, clf // Define your variables

stacksize('max')

t1 =[0:0.01:100];

y1=25+75 ./(1+exp((t1-50)/10));

t2=[0:0.01:100];

y2 = -10 *log((75/t2-25)-1) + 50;

// Use the logflag option to define logarithmic or normal axis

// n for normal, l for logarithmic.

plot(t1,y1,t2,y2)

// Use xgrid to add a grid on your current figure

xgrid;

I've added an asterisk before log and removed the dot operator before -1.

I get a plot but there is a warning-

WARNING: Transposing row vector X to get compatible dimensions

Also, you have to increase the stacksize to max as the code exceeds the stack size allocation.

Based on y1, I get y2 to be 10 .*log(((75)./(t2-25))-1) + 50. It is different from the y2 you have calculated. I'm not sure the range you have selected is correct. When t2=100, it becomes log(0) which leads to an error. I've modified the code to this-

clc

clear

t1 =[1:10:100];

y1=25+(75)./(1+exp((t1-50)/10));

t2=[1:10:100];

g=((75)./(t2-25))-1

y2 = 10 .*log(g) + 50

plot(t1,y1,t2,y2)

xgrid;

Please check if the plot is correct now.

Hello again,

Login to add comment

Please check the code now-

clc

clear

t1 =[1:0.1:99.9];

y1=25+(75)./(1+exp(-(t1-50)/10));

t2=[1:0.1:99.9];

y2=zeros(size(t2,1),1)

for t=1:length(t2)

if (t2(t)==25) then // ln(0) is an error. Equate it to zero.

y2(t)=0;

else

y2(t) = -10 *(log(((75)./(t2(t)-25))-1)) + 50;

end

end

plot(t1,y1,t2,y2')

ax=gca();

ax.data_bounds=[25 25;120 120];

xgrid;

For the range you've chosen, no value exists for ln(0) and division by zero. We have to handle such exceptions in the code. Please check the plot now. y2 exists for values below t2<25.I've plotted only from t2>=25 to match the plot you have shown.

thanks for that, it looks like there might be something wrong with the equation I am using for y2.

25-04-16, 3:54 p.m.rinkleyWhat is the equation for y2?

25-04-16, 3:55 p.m.shamikaWell I am meant to find the inverse of the function f y1=25+75 ./(1+exp((t1-50)/10))

26-04-16, 2:49 p.m.rinkleyLogin to add comment