Ask Experts Questions for FREE Help!
Ask    ||    Answer
 
Advanced  
 

Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
Free Answers in 3 Easy Steps

Register Now
3 Steps

At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.

Home > Science > Mathematics   »   Recursive Matlab problem

 
Thread Tools Search this Thread Display Modes
Question
 
 
#1  
Old Mar 10, 2003, 11:26 PM
Gemma82au
New Member
Gemma82au is offline
 
Join Date: Mar 2003
Location:
Posts: 1
Gemma82au See this member's comment history on his/her Profile page.
Send a message via ICQ to Gemma82au
Recursive Matlab problem

Hi, im trying to write a matlab program for a recursive sequence. I worked out the sequence right i think but cant get the figures right in the program. Heres the program I have so far:

%recursive program for water
%dam cycling down to empty

clear
format long
A=32;
fprintf(' Week Megalitres\n\n');

for n=1:10;
A=A+9-3*n;

disp([n A])
end

These are what i get-

Week Megalitres

1 38

2 41

3 41

4 38

5 32

6 23

7 11

8 -4

9 -22

10 -43

But these are the figures i require-

1 38

2 42

3 44

4 44

5 42

6 38

7 32

8 24

9 14

10 2

The problem is where i have 3*n it should be be going up by 2(n+1) at a time. ie 3,5,7,9 whereas mine is going up as 3,6,9,12.

Can anybody see where ive got it wrong?
Thankyou

Reply With Quote
 
     

Answers
 
 
Old Mar 22, 2003, 10:02 AM   #2  
New Member
dtecmeister is offline
 
Join Date: Mar 2003
Location:
Posts: 6
dtecmeister See this member's comment history on his/her Profile page.
Send a message via ICQ to dtecmeister
Re: Recursive Matlab problem

I'm not used to Matlab, but I think you need to do the following:
clear
format long
A=38;
fprintf(' Week Megalitres\n\n');

for n=1:10;
disp([n A])
A=A-(2*(n-4))

end
  Reply With Quote
 
     

Your Answer
Email me when someone replies to my answer
Join Login





Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

 
Similar Sponsors


Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page

Similar Threads
Pi by recursive decimal places
(3 replies)
Playboy girlfirend problem.. real problem
(14 replies)
Matlab Help Please!!
(0 replies)
finding area using MATLAB
(0 replies)

Search this Thread

Advanced Search

Bookmarks

Sponsors



Copyright ©2003 - 2009, Ask Me Help Desk.
All times are GMT -8. The time now is 10:35 AM.