Plotting a solution Function Graph
Show older comments
I need the graph of this function. I tried to write MATLAB codes. But i couldn't manage. Please help me.
From now, thanks.

11 Comments
Steven Lord
on 30 May 2021
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.
zekeriya özkan
on 31 May 2021
Walter Roberson
on 31 May 2021
See piecewise()
Note; in order to use matlabFunction() with piecewise(), you must tell matlabFunction() to write to a file.
zekeriya özkan
on 31 May 2021
If someone might try to program your function:
I guess there is a mistake in the definition of phi(i). A product of mu*(theta(m+1)-theta(m)) is running from
m = i to m = i-1. This would mean that the product is empty and always has a value of 1 per definition.
My guess is that it should run from m = k to m = i-1
zekeriya özkan
on 31 May 2021
Edited: zekeriya özkan
on 26 Jun 2021
here, the number of intervals are very very much. So I couldn't manage to write codes using loops and conditions.
Oh?
n = 100;
syms x
y = sym(0);
for k = 1 : n
y = y + piecewise(x <= k & x < k + 1, x/k, 0);
end
y
Loops and conditions seem to generally work fine to build piecewise expressions.
(Building the expression in this particular manner slows down as it goes; you can reduce that by breaking the task up into pieces. For example, you could create the expression for 1 to 5, and 5 to 9, 10 to 14, 15 to 19, 20 to 24, and add those together. Do the same thing for three other groups of 5. Then at the end add the four groups of 25. This kind of decomposition of the additions into sizes that are prime factors reduces the total work required to merge the conditions into their proper order.
zekeriya özkan
on 26 Jun 2021
And... ?
n = 10;
syms x
y = sym(0);
for k = 1 : n
y = y + piecewise(x <= k & x < k + 1, x/k, 0);
end
y
I do not see why you could not use loops and piecewise() to build up expressions ?
zekeriya özkan
on 28 Jun 2021
Walter Roberson
on 28 Jun 2021
I do not see your code attempt posted? This question has longer formulas, and the volunteers are not going to bother typing everything in from scratch to show you the resulting code just to prove that it can be done.
Answers (0)
Categories
Find more on Calculus 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!
