Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
coupled problem - coded (is it correct??)

Subject: coupled problem - coded (is it correct??)

From: Niraj

Date: 4 Nov, 2012 08:51:10

Message: 1 of 3

Dear frnds,

look into my code and please suggest the changes if you find any error

a = 0;
b= -0.2;
muo= 0.5;
dc = .001;
vo = .001;
k = 1000000;
dt = 1;
theta = dc/vo;
thetaold = theta;
v = vo;
loop = 0;
change =0;
while 0< change <.001
loop = loop+1;

    %%vtrue calculation
    v = 2*vo +(1/k)*(a*(v-vo))*(1/dt)+ b*v*(1/(2*vo))*log((v*theta)/dc) ;
       %temperature calculation
      
            theta = theta - v*theta*(1/dc)*(dt)*log((v*theta)/dc);
end
          change = v-vold;
          plot(v);

Subject: coupled problem - coded (is it correct??)

From: Justin Ashmall

Date: 5 Nov, 2012 11:08:09

Message: 2 of 3

Whilst this looks like some kind of valid code, it's not valid MATLAB.

I'm guessing you've never written any MATLAB at all, so jumping right in with a step-wise differential is probably not the best tutorial.

Take a look here for lots of resources.
http://www.mathworks.com/academia/student_center/tutorials/launchpad.html

Pay particular attention to loops and arithmetic and matrrix operations (i.e. "*" and "/").

Justin


"Niraj " <niraj.jha@rub.de> wrote in message <k75a9u$p56$1@newscl01ah.mathworks.com>...
> Dear frnds,
>
> look into my code and please suggest the changes if you find any error
>
> a = 0;
> b= -0.2;
> muo= 0.5;
> dc = .001;
> vo = .001;
> k = 1000000;
> dt = 1;
> theta = dc/vo;
> thetaold = theta;
> v = vo;
> loop = 0;
> change =0;
> while 0< change <.001
> loop = loop+1;
>
> %%vtrue calculation
> v = 2*vo +(1/k)*(a*(v-vo))*(1/dt)+ b*v*(1/(2*vo))*log((v*theta)/dc) ;
> %temperature calculation
>
> theta = theta - v*theta*(1/dc)*(dt)*log((v*theta)/dc);
> end
> change = v-vold;
> plot(v);

Subject: coupled problem - coded (is it correct??)

From: Torsten

Date: 5 Nov, 2012 11:28:08

Message: 3 of 3

"Niraj " <niraj.jha@rub.de> wrote in message <k75a9u$p56$1@newscl01ah.mathworks.com>...
> Dear frnds,
>
> look into my code and please suggest the changes if you find any error
>
> a = 0;
> b= -0.2;
> muo= 0.5;
> dc = .001;
> vo = .001;
> k = 1000000;
> dt = 1;
> theta = dc/vo;
> thetaold = theta;
> v = vo;
> loop = 0;
> change =0;
> while 0< change <.001
> loop = loop+1;
>
> %%vtrue calculation
> v = 2*vo +(1/k)*(a*(v-vo))*(1/dt)+ b*v*(1/(2*vo))*log((v*theta)/dc) ;
> %temperature calculation
>
> theta = theta - v*theta*(1/dc)*(dt)*log((v*theta)/dc);
> end
> change = v-vold;
> plot(v);

First of all we need to know what your code should do ...

Best wishes
Torsten.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us