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
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
zekeriya özkan 2021 年 5 月 31 日
I know MATLAB essentials but i couldn't write piecewise function MATLAB codes. Please help.
Walter Roberson
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
zekeriya özkan 2021 年 5 月 31 日
I know to use piecewise function but here, the number of intervals are very very much. So I couldn't manage to write codes using loops and conditions.
Please help.
Torsten
Torsten 2021 年 5 月 31 日
編集済み: Torsten 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
zekeriya özkan 2021 年 5 月 31 日
編集済み: zekeriya özkan 2021 年 6 月 26 日
Dear Torsten,
It is not mu*(theta(m+1)-theta(m))
but
mu(theta(m+1)-theta(m))
i.e. this is the value of function mu at (theta(m+1)-theta(m)) .
I corrected that mistake. Please help.
Walter Roberson
Walter Roberson 2021 年 5 月 31 日
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
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
zekeriya özkan 2021 年 6 月 26 日
Dear Friend Walter;
We can chose n=10.
Walter Roberson
Walter Roberson 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
y = 
I do not see why you could not use loops and piecewise() to build up expressions ?
zekeriya özkan
zekeriya özkan 2021 年 6 月 28 日
Dear Walter, can you help me to write for plotting codes of the function using loops? Because, i couldn't manage.
Walter Roberson
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 件)

カテゴリ

製品

リリース

R2020a

タグ

質問済み:

2021 年 5 月 30 日

コメント済み:

2021 年 6 月 28 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by