• ISHAN

MemberOct 23, 2013

## Matlab: How to find answers repeatedly by inserting values?

I have a programming doubt. The doubt is simple.

"syms a b c;
a=b+c;
b=3; c=1;"

The above is the program. Now when I do b+c, I get answer as 4. But when I want to find the value of a,
the system says a=b+c.

It should say a=4. But it does not.

Another doubt is that, if I keep on changing values of b and c, can I get different values of a?

Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
• MemberOct 23, 2013

Issue
I have a programming doubt. The doubt is simple.

"syms a b c;
a=b+c;
b=3; c=1;"

The above is the program. Now when I do b+c, I get answer as 4. But when I want to find the value of a,
the system says a=b+c.

It should say a=4. But it does not.

Another doubt is that, if I keep on changing values of b and c, can I get different values of a?

Well I am not pro in MATLAB but I see you have assigned b=3 and c=1 after a=b+c; that may be the reason you are not getting proper value.

Try this
"syms a b c;
b=3; c=1;
a=b+c;"
I think this should work for you.
Are you sure? This action cannot be undone.
• MemberOct 23, 2013

Thanks brother. It worked!
but the problem is only partially solved. Say I have an equation,
Y=3X+2;
Now I want values of Y for X=1,2,3...

Then what to do? Each time I do not want to type the equation. Nor do I want to plot X,Y 😔
Are you sure? This action cannot be undone.
• MemberOct 23, 2013

Prof.Rudra Pratap's book 'Getting Started With Matlab: A quick introduction for scientists and engineers' published by Oxford University Press is very good for this. Written in a casual style it gets you going fast. I have the book for Matlab v.6. I can vouch for its excellence. (Available from college book stores at a concession. I bought it at IISC, Bangalore)
Free eBooks are available here:

(Note: I do not know anything about the legality of this site.
Are you sure? This action cannot be undone.
• MemberOct 23, 2013

Issue
Thanks brother. It worked!
but the problem is only partially solved. Say I have an equation,
Y=3X+2;
Now I want values of Y for X=1,2,3...

Then what to do? Each time I do not want to type the equation. Nor do I want to plot X,Y 😔
Well you can use some kind of array for that. Let me make one example for you.
Are you sure? This action cannot be undone.
• MemberOct 23, 2013

A.V.Ramani
Prof.Rudra Pratap's book 'Getting Started With Matlab: A quick introduction for scientists and engineers' published by Oxford University Press is very good for this. Written in a casual style it gets you going fast. I have the book for Matlab v.6. I can vouch for its excellence. (Available from college book stores at a concession. I bought it at IISC, Bangalore)
Free eBooks are available here:

(Note: I do not know anything about the legality of this site.
Agree ! not sure about the legality about that site as there are lot of different books posted.

You want something like this right?
Are you sure? This action cannot be undone.
• MemberOct 23, 2013

Agree ! not sure about the legality about that site as there are lot of different books posted.

You want something like this right?
@#-Link-Snipped-# ramani: Thankyou sir, I will check that book from college library tomorrow(first thing). 😀

@#-Link-Snipped-# Yes I want same type of output.
Are you sure? This action cannot be undone.
• MemberOct 23, 2013

Using arrays is really simple try using

a=b.+c
a=b.*c

All these simple modifications allow you to perform any operation in which the inputs are sequences

Remember the fact that '.' (full stop) allows you to perform manipulations of arrays of input

But balancing inputs are needed i.e Basic rules which govern array computation have to be followed here also
Are you sure? This action cannot be undone.