Wrong equastion of XY dependence
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Pavol Namer
el 7 de Ag. de 2014
Comentada: Pavol Namer
el 7 de Ag. de 2014
Hi I try to solve following problem.
I try to type following equastion of XY dependence:
x= [-5,15]
a= 1
b= 12
c= 2.4
r= 1
y= -1*(a-b*(((x)-r)).^4).*(exp(-1*c*((x)-r).^2))
figure
plot (x,y)
it should be this equation:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154110/image.jpeg)
And it should have this shape of XY dependence
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154111/image.png)
But it give me the wrong shape (like linear XY dependence).
Can anybody advise, where the mistake i?
Thank you
P.
0 comentarios
Respuesta aceptada
Mischa Kim
el 7 de Ag. de 2014
Editada: Mischa Kim
el 7 de Ag. de 2014
Use,
x = -5:0.1:15; % create a vector x, element spacing: 0.1
a = 1;
b = 12;
c = 2.4;
r = 1;
y = -1*(a-b*(((x)-r)).^4).*(exp(-1*c*((x)-r).^2));
figure
plot(x,y)
The only difference is in the first line. In your code you evaluate y only twice, at x = -5 and at x = 15.
Más respuestas (1)
David Sanchez
el 7 de Ag. de 2014
Instead of your definition of x, try the folowing one:
x= -5:.01:15; % array of 2001 elements, your definition were a mere 2 element array
a= 1;
b= 12;
c= 2.4;
r= 1;
y= -1*(a-b*(((x)-r)).^4).*(exp(-1*c*((x)-r).^2));
figure
plot (x,y)
0 comentarios
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!