can anyone help me solve these two questions please?
Show older comments
1.Write a MATLAB program to find the value of f(x) is -2x when x < 0; x(x-2) when x is in [0, 2] and log(x-1) otherwise.
2. write a MATLAB program to find out the sum of the first 10 numbers in fribonacci series.
TIA
Answers (2)
Sibi
on 6 Nov 2020
Edited: madhan ravi
on 6 Nov 2020
1)
F=(x<0)*(-2*x)+(x<=2)*(x>=0)*(x*(x-2))+(x>2)*(log(x-1));
2)
Y=sum(fibonacci(1:10));
8 Comments
madhan ravi
on 6 Nov 2020
Edited: madhan ravi
on 6 Nov 2020
Answering a homework question with a full solution is strongly discouraged in this forum.
John D'Errico
on 6 Nov 2020
Please don't do homework assignments for people. It does not help them, nor does it teach them anything but that a sucker is to be found here who will do my homework for me.
Sibi
on 6 Nov 2020
Okay
John D'Errico
on 6 Nov 2020
Try to use this rule - the more the student has made an effort of their own, the more you can be willing to help them. For example, if a student shows the problem, then shows that they tried, and you can see they were totally correct in that they did, except for a minor bug? Then just show them how to fix it. They knew what to do, and how to solve the problem already, and they were forthcoming with their attempt. Essentially, this student is interested in learning, and they can benefit from what you show them.
An example is if a student has the correct code, but does not understand the difference between the * and .* operators? Now you can explain that difference, and show where the .* operator is necessary.
But suppose the student shows code that is haphazard, not at all on-target to solve the problem (but at least shows code)? Now you want to point them in a reasonable direction. Perhaps suggest they look at some functions that will help them to solve their problem. But don't write the code for that student. You might suggest they take the Onramp tutorial, if they seem to have no real clue about coding, but at least made an attempt.
For example, just recently, I spent roughly an hour writing up a lengthy description of how to find a function that will solve a problem, using the help tools in MATLAB. This was for a student who seemed to care about learning.
Last, suppose a student does nothing but post a picture of their homework assignment, and demand help soon with no effort shown, because their homework is due in a few hours? Oh, thats right, I probably closed that question already, before you even saw it. :) This student has no interest in learning, just in a grade on their homework.
Essentially, the more effort a student puts in, the more you can help them. I've seen students who show a real interest in what they see, coming back with interesting followup questions. That is the student who I truly respect and enjoy helping.
madhan ravi
on 6 Nov 2020
:)
Sibi
on 6 Nov 2020
Sure I'll follow this,thank you.
rsn
on 7 Nov 2020
John D'Errico
on 7 Nov 2020
@rsn - If you want help here, then you need to show some effort. Otherwise, you have shown no more interest than someone who wants nothing more than to get their homework answered.
help fibonacci
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!