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?

@#-Link-Snipped-# can you help me?

Replies

  • Harshad Italiya
    Harshad Italiya
    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?

    @#-Link-Snipped-# can you help me?
    Hey @#-Link-Snipped-#,
    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.
  • ISHAN TOPRE
    ISHAN TOPRE
    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 😔
  • Ramani Aswath
    Ramani Aswath
    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:
    #-Link-Snipped-#


    (Note: I do not know anything about the legality of this site.
    @#-Link-Snipped-#, is this OK?)
  • Harshad Italiya
    Harshad Italiya
    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.
  • Harshad Italiya
    Harshad Italiya
    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:
    #-Link-Snipped-#


    (Note: I do not know anything about the legality of this site.
    @#-Link-Snipped-#, is this OK?)
    Agree ! not sure about the legality about that site as there are lot of different books posted.

    @#-Link-Snipped-# Have a look at this :- #-Link-Snipped-#
    You want something like this right?
  • ISHAN TOPRE
    ISHAN TOPRE
    Harshad Italiya
    Agree ! not sure about the legality about that site as there are lot of different books posted.

    @#-Link-Snipped-# Have a look at this :- #-Link-Snipped-#
    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.
  • Jeffrey Arulraj
    Jeffrey Arulraj
    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

You are reading an archived discussion.

Related Posts

A fine bit of engineering in action. Quote: A remarkable video released by SpaceX, the space transport company founded by Elon Musk, demonstrates a test of their latest rocket in...
hello friends every body uses the cell phones now a days and everybody faces the normal curcumstances like balance cutting and something other.And there is not any problem then also...
why the inlet valve diametre is more than exhaust valve diametrer?
hello friends now a days email id is becomes a very essential idetity tool for every body. But till now i was very tensioned about my mail box because i...
Hello, Paypal gives two options to get verified, either adding bank account details, or the debit card details. Which option is the best? And are there any pros or cons...