Matlab m file function with multiple variables


by strokebow
Tags: file, function, matlab, multiple, variables
strokebow
strokebow is offline
#1
Oct10-11, 02:51 AM
P: 101
Hi,

I have a matlab function m file and I want to integrate the function.

function y = myfun(t,a,b)

y = (1/(2*pi)).*(1./t)*(1i*(a+b));
end

Then when I call the integration in matlab I dont know how to specify a and b whilst integrating over t.

I need to be able to set a and b outside of the function m file and then call the integral.

R=quadgk(@myfun,0,Inf)
This command will not work. a and b need to be set. I want to set a and b (this can vary) and then run the integral. I have tried set a and b in the matlab workspace but that still doesnt work.

Please can anyone help?
** Also, please let me know if my explanation is not clear?

Thanks
Phys.Org News Partner Science news on Phys.org
Lemurs match scent of a friend to sound of her voice
Repeated self-healing now possible in composite materials
'Heartbleed' fix may slow Web performance
strokebow
strokebow is offline
#2
Oct10-11, 03:16 AM
P: 101
Solved it.

Its how you call the function.

It should be:

R=quadgk(@(t)myfun(t,a,b),0,Inf)

simples.
mhmz66
mhmz66 is offline
#3
Oct24-11, 01:56 AM
P: 1
hi to all
I have a problem with timer in gui in matlab
i wanna to show real time in gui figure but when run the timer mfile it create a new figure
seperatly from main figure

any one can help me?
if know a way for this problem please help me ....
my email address is : mhmz66@yahoo.com
tnx so much


Register to reply

Related Discussions
Parity of function of multiple variables General Math 5
Multiple Regression with four variables? Also in MATLAB General Math 1
matlab function (M-File) that will create & play a sinusoidal waveform Engineering, Comp Sci, & Technology Homework 0
representing a function of three variables in matlab Math & Science Software 0
zeros to function of 2 variables, Matlab. Math & Science Software 1