how can i do this ?

8 ビュー (過去 30 日間)
m
m 2014 年 3 月 21 日
コメント済み: m 2014 年 3 月 22 日
i must plot a graph like this:
(there are many functions that are valid for difference particular time in a period, for example for td interval function 1 is valid, for tr interval function 2 is valid...)
a code like this is okey:
x=0:0.1:1;
a=x.^2;
y=1:0.1:2;
b=y.^3;
z=2:0.1:3;
c=z.^3;
plot(x,a,y,b,z,c);
but i have to plot these functions, there is a mistake, would you help me please ?
k=0:10.^-12:6.9*10.^-9;
a=25*10.^-6*80;
l=6.9*10.^-9:10.^-12:2.29*10.^-8;
b=25*10.^-6*l./(16*10.^-9)*(80+(2.16-80)*l./(16*10.^-9));
m=2.29*10.^-8:10.^-12:2.5*10.^-6;
c=4*2.16;
n=2.5*10.^-6:10.^-12:2.515*10.^-6;
d=4*2.16;
o=2.515*10.^-6:10.^-12:2.5244*10.^-6;
e=80*4*((1-o./(9.4*10.^-9))*o./(9.4*10.^-9));
p=2.5244*10.^-6:10.^-12:5*10.^-6;
f=25*10.^-6*80;
plot(k,a,l,b,m,c,n,d,o,e,p,f);
??? Error using ==> mtimes
Inner matrix dimensions must agree.
  2 件のコメント
Patrik Ek
Patrik Ek 2014 年 3 月 21 日
I you just want a nice plot I would recommend inkscape or paint, or any other program. Doing this in matlab is just a pain. Are you sure the equations are correct? also, you can just catenate the array and thus get rid of
plot(so many variables that I have no control and will definitely have an error);
Another advice is to plot each set one by one fix one at the time.
m
m 2014 年 3 月 22 日
thanks for helping i must ask somethings to my teacher

サインインしてコメントする。

採用された回答

A Jenkins
A Jenkins 2014 年 3 月 21 日
編集済み: A Jenkins 2014 年 3 月 21 日
On the lines where you calculate b, and e, you probably want to use the element-wise multiplication .* instead of the matrix multiplication * between your two halves. For example:
b=25*10.^-6*l./(16*10.^-9).*(80+(2.16-80)*l./(16*10.^-9));
Also, I think you will want c,d, and f to be arrays, not scalars. For example:
c=4*2.16*ones(size(m));
  3 件のコメント
A Jenkins
A Jenkins 2014 年 3 月 21 日
編集済み: A Jenkins 2014 年 3 月 21 日
What exactly do you need help with? The other posters are right that your numbers don't make sense. For example, the value of "a" is 0.002, and the value of "e" is approximately -22,821,490. These are not going to show up nicely on the same plot.
Here is an example similar to your code with numbers that makes a nice plot. But we do not know what your numbers should be.
k=1:1:10;
a=25*ones(size(k));
l=10:1:20;
b=(l-10).^2+25;
m=20:1:30;
c=125*ones(size(m));
n=30:1:35;
d=-(n-30).^3+125;
o=35:1:40;
e=0*ones(size(o));
plot(k,a,l,b,m,c,n,d,o,e);
m
m 2014 年 3 月 22 日
thank you for the graph and code

サインインしてコメントする。

その他の回答 (3 件)

Joseph Cheng
Joseph Cheng 2014 年 3 月 21 日
You are missing some (.*) in both b= and e=. However your a,b,c,d,e,f curves doesn't match the pictured curve.
  1 件のコメント
m
m 2014 年 3 月 21 日
i have done it but it gives me another result that is not my purpose

サインインしてコメントする。


m
m 2014 年 3 月 21 日
編集済み: m 2014 年 3 月 21 日
i could not solve again,
the function goes to any j number(s) between any x and y times and i have 6 function in a period
how can i do this ? the picture is an example only it is not valid for this question

Joseph Cheng
Joseph Cheng 2014 年 3 月 21 日
So you are not just plotting you are trying to find the point on the curve for any t?
They you are best off forming this into one array and not spread across multiple arrays.
example:
t=0:10e-12:5e-6;
A = zeros(size(t));
A(t>=0 & t<=6.9e-9) = 25e-6*80;
tempT =t(t>6.9e-9 & t<=2.29e-8);
A(t>6.9e-9 & t<=2.29e-8) = 25*10^-6*tempT./(16*10^-9).*(80+(2.16-80)*tempT./(16*10^-9));
A(t>2.29e-8 & t<2.5e-6)= 4*2.16;
  2 件のコメント
m
m 2014 年 3 月 21 日
編集済み: m 2014 年 3 月 21 日
if i could understand you you are wrong. i do not want to find any points. i want to plot a graph of these functions only. my graph will resemble to picture above. my purpose is plotting a graph like that
m
m 2014 年 3 月 21 日
編集済み: m 2014 年 3 月 21 日
hey guys would you help me please
teacher said to us it is handy to use "for loop"

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by