Plotting a solution Function Graph
이전 댓글 표시
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
Steven Lord
2021년 5월 30일
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
2021년 5월 31일
Walter Roberson
2021년 5월 31일
See piecewise()
Note; in order to use matlabFunction() with piecewise(), you must tell matlabFunction() to write to a file.
zekeriya özkan
2021년 5월 31일
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
2021년 5월 31일
편집: zekeriya özkan
2021년 6월 26일
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
2021년 6월 26일
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
2021년 6월 28일
Walter Roberson
2021년 6월 28일
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.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

