Question

Creat a matlab function that calculates: f(x, y) = xy/(exp(x) + exp(-y)) for two vectors of values x and y. Name your functio
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code to call the function script:
x=-4:0.5:4;
y=-5:1:5;
A=function_xy(x,y)

Function script:

function f=function_xy(x,y)
m=min(min(x),min(y)):0.5:max(max(x),max(y));
x1=zeros(1,length(m));
x1(find((m>=min(x))&(m<=max(x))==1))=x;
x=x1;
y1=upsample(y,2);
y=y1(1:length(x1));
f=(x.*y)./(exp(x)+exp(-y));
end

Output

A =

Columns 1 through 13:

-0.00000 0.00000 0.29295 -0.00000 0.44698 -0.00000 0.53160 -0.00000 0.32403 -0.00000 0.00000 0.00000 0.32403

Columns 14 through 21:

0.00000 0.53160 0.00000 0.44698 0.00000 0.29295 0.00000 0.0000

Add a comment
Know the answer?
Add Answer to:
Creat a matlab function that calculates: f(x, y) = xy/(exp(x) + exp(-y)) for two vectors of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT