Login | Register
The Engineer's Place for News and Discussion®

Previous in Forum: Did They Lie (Not Quite Tell the Truth) to Me?   Next in Forum: Digitizing Tablets
Close

Comments Format:






Close

Subscribe to Discussion:

CR4 allows you to "subscribe" to a discussion
so that you can be notified of new comments to
the discussion via email.

Close

Rating Vote:







10 comments
Associate
Engineering Fields - Optical Engineering - A New Member Engineering Fields - Retired Engineers / Mentors - A New Member Engineering Fields - Energy Engineering - New Member

Join Date: Mar 2011
Posts: 41

Matlab GUI Begineer + Hobbyist (MATLAB Only)

08/27/2012 3:15 AM

Hi,

I am trying to write a simple Compund interest program.

Principal = p ; Interest rate= r ; Time = t ; Pay Scheme = n ; Amount = A

the equation used :< A=p*(1+(r/n))^(n*t) > with this I get the amount successfully.

But I want to have a plot of amount and time: <plot(a,t)> and I am getting no result.

I refered some different programs and they are calling functions from a different m-file. SO I tried to write the m-file of amount and call it but it just doesnt work.

I would be very graeful if some one could teach me how to do call function.

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru
Hobbies - Automotive Performance - New Member Popular Science - Weaponology - New Member

Join Date: Oct 2008
Location: 34° 34' 21.60" N, 92° 55' 42.28" W
Posts: 20974
Good Answers: 786
#1

Re: Matlab GUI Begineer + Hobbyist (MATLAB Only)

08/27/2012 10:56 AM

Don't have a spread sheet?

__________________
Luck comes and goes. Skill is forever. Intelligence either is, or it ain't. lyn
Register to Reply
Associate
Engineering Fields - Optical Engineering - A New Member Engineering Fields - Retired Engineers / Mentors - A New Member Engineering Fields - Energy Engineering - New Member

Join Date: Mar 2011
Posts: 41
#2
In reply to #1

Re: Matlab GUI Begineer + Hobbyist (MATLAB Only)

08/27/2012 11:18 AM

No, I dont think it is needed here

Register to Reply
Guru
Engineering Fields - Optical Engineering - Member Engineering Fields - Engineering Physics - Member Engineering Fields - Systems Engineering - Member

Join Date: Apr 2010
Location: Trantor
Posts: 2967
Good Answers: 298
#3

Re: Matlab GUI Begineer + Hobbyist (MATLAB Only)

08/28/2012 12:37 AM

I'm not familiar with Matlab. I have used Mathcad for years.

You might want to consider getting Mathcad instead, unless you need Matlab for a specific application. Or, do this with Excel.

Anyway, here's your problem as written and graphed in Mathcad. Maybe this will give you some insight on how to formulate it in Matlab. I just picked some dummy values for your constants. For example, t is the running variable, taking values from 1 to 10. I then plot A(t) against t.

__________________
"...any library is a good library that does not contain a volume by Jane Austen. Even if it contains no other book." - Mark Twain
Register to Reply
Associate

Join Date: Jun 2012
Location: USA
Posts: 32
#5
In reply to #3

Re: Matlab GUI Begineer + Hobbyist (MATLAB Only)

08/28/2012 9:41 AM

What are differences between MATLAB and MATHCAD ?

__________________
Solutions to all EMC problems! check this out... www.microvolt.com
Register to Reply
Guru
Engineering Fields - Optical Engineering - Member Engineering Fields - Engineering Physics - Member Engineering Fields - Systems Engineering - Member

Join Date: Apr 2010
Location: Trantor
Posts: 2967
Good Answers: 298
#10
In reply to #5

Re: Matlab GUI Begineer + Hobbyist (MATLAB Only)

08/29/2012 1:29 PM

Both Matlab and Mathcad have been around in various forms since the early 80s. I've never used Matlab, but from what I've seen it looks a lot less user friendly than Mathcad. Mathcad is like having a live notebook. You define an equation in its workspace and it instantly solves it for you. It can handle all algebra and trig functions, and nearly all higher math including differential and integral calculus, and it uses 'realistic' symbology (menu-driven), so that it looks just like you'd write the equation by hand in a notebook. It also allows for 'do loop' programming (for ex.), plus symbologic algebraic solving of equations. It does 2D and 3D graphing and has a 'movie mode' for animations.

From what I've seen of pricing, Mathcad is also much more affordable for the casual user. It is only available for Windows. Here is some info about Mathcad:

http://www.ptc.com/product/mathcad/?gclid=CI6MpbiqjbICFQqR7QodRwoAKA

You can download a 30 day free trial here, if you don't mind giving them some personal info:

http://www.ptc.com/product/mathcad/free-trial/

__________________
"...any library is a good library that does not contain a volume by Jane Austen. Even if it contains no other book." - Mark Twain
Register to Reply
Participant

Join Date: Dec 2011
Posts: 4
#4

Re: Matlab GUI Begineer + Hobbyist (MATLAB Only)

08/28/2012 2:30 AM

Dear Friend,
in your example have taken Amount =A, but in plot you are taking a, so kindly take the value as "A" instead of "a".This given blow example will be helpful for you.So go through same.Example
clear,clcformat compacts0 = 12000K = 9600%Define the values of grain diameterdiameter = 0.1:0.1:10;yield = HallPetch(s0,K,d);%Plot the resultsfigure(1)plot(diameter,yield)title('Yield strengths found with the Hall-Petch equation')xlabel('diameter, mm')ylabel('yield strength, psi')

Register to Reply
Guru

Join Date: Apr 2010
Posts: 544
Good Answers: 26
#6

Re: Matlab GUI Begineer + Hobbyist (MATLAB Only)

08/28/2012 6:49 PM

%PASTE THIS INTO COMMAND WINDOW

p=(fill in); %constant, put your number in place of (fill in);

r=(fill in); %constant, put your number in place of (fill in);

dt=(fill in); %constant, put your number in place of (fill in);

n=(fill in); %constant, put your number in place of (fill in);

N=(fill in); %constant, put your number in place of (fill in);

for I=1:N

t(I)=I*dt;

end

A=p*(1+(r/n))^(n*t);

plot(t,A);

grid on;

%END OF PASTE

This should work. Everything after % is a comment and ignored by MATLAB. N is number of steps, dt is step size, total amount of time is N*dt. Put your numbers in place of (fill in). Copy and paste into Matlab command window.

Register to Reply
Guru

Join Date: Apr 2010
Posts: 544
Good Answers: 26
#9
In reply to #6

Re: Matlab GUI Begineer + Hobbyist (MATLAB Only)

08/29/2012 7:37 AM

Error in formula... Here is corrected code with some numbers filled in.

p=(100);

r=(.06);

dt=(.05);

n=(1);

N=(1000);

for I=1:N

t(I)=I*dt;

end

A=p*(1+(r/n)).^(n*t); % Note: You need .^ because n*t is a vector!

plot(t,A);

grid on;

Register to Reply
Associate
Engineering Fields - Optical Engineering - A New Member Engineering Fields - Retired Engineers / Mentors - A New Member Engineering Fields - Energy Engineering - New Member

Join Date: Mar 2011
Posts: 41
#7

Re: Matlab GUI Begineer + Hobbyist (MATLAB Only)

08/29/2012 3:49 AM

lets suppose I have to call m-file inside another m-file (which contains the main program) can any one show me a small syntax or an example.

It will be very helpful, the e-book which I am following is not very clear to me.

Register to Reply
Guru

Join Date: Apr 2010
Posts: 544
Good Answers: 26
#8
In reply to #7

Re: Matlab GUI Begineer + Hobbyist (MATLAB Only)

08/29/2012 6:37 AM

Create an m file called RectangleArea.m

In this file:

function [ Area ] = RectangleArea( length, width )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
Area = length*width;

end

In you main program:

l=5;

w=2;

A=RectangleArea(l,w);

Make sure RectangleArea.m is in your path where Matlab can find it.

Register to Reply
Register to Reply 10 comments
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Copy to Clipboard

Users who posted comments:

cbob12 (1); hariombaboo (1); lyn (1); Rixter (3); Shoeb (2); Usbport (2)

Previous in Forum: Did They Lie (Not Quite Tell the Truth) to Me?   Next in Forum: Digitizing Tablets