Homework for tomorrow please

2 Ansichten (letzte 30 Tage)
Ilie Mihai
Ilie Mihai am 11 Mai 2017
Kommentiert: Matt J am 11 Mai 2017
[-5:0.2:5]
k=max(size(x));
for i=1:k
if ((x(i)>=-5)&(x(i)<1))
y(i)=atan(x(i)+1)+(x(i)-10.04)^7+(10.04-7)^(1/5)+3^(x(i)+2)+sin(2*x(i)-10.04)-tan(2*x(i)-6);
end
if ((x(i)>=1)&(x(i)<=-5))
y(i)=acot(x(i)+10.04)+(x(i))^9+5^(x(i)+8)+(10.04+2)^(1/6)-log((x(i)+2))^4-cos(5*10.04-4);
end
end
WHY I CANT using PLOT ????
Please, i really need help for homework for tomorrow and i HAVE 15 PROBLEMs and i have no idea how to do these
Can someone help me with all of these ? Plese contact me

Antworten (3)

Star Strider
Star Strider am 11 Mai 2017
One reason is that you have not called the plot function in the code you have posted. We cannot tell if you are calling it correctly. (However, if you need our permission to use plot, you have it!)
Also this line:
[-5:0.2:5]
is just sitting in your code with nothing to do. What do you want it to do?
I understand your desperation, since I suspect most if not all of us here have been in your situation at least once. Please take a deep breath and explain your problem in sufficient detail that we can understand it and help you solve it.

Matt J
Matt J am 11 Mai 2017
Hint: Your mistake is somewhere in here
((x(i)>=1)&(x(i)<=-5))
  1 Kommentar
Matt J
Matt J am 11 Mai 2017
you should also pre-allocate y
x=[-5:0.2:5];
k=numel(x);
y=nan(1,k);
...

Melden Sie sich an, um zu kommentieren.


Jan
Jan am 11 Mai 2017
The first line [-5:0.2:5] creates a vector but as long as it is not assigned, it is lost. Perhaps you mean x = -5:0.2:5; ? See avoid unnecessary square brackets
If you state, that you "cannot use plot", please share the information with us: There is no plot command in the posted code. Therefore I cannot guess, what happens on your computer. But if you are really in a hurry, it is your interest to explain the actual problem.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by