simple problem about plotting
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Geonhee LEE
el 8 de Ag. de 2016
Editada: Walter Roberson
el 8 de Ag. de 2016
hello guys;
I am trying to plot a mathematics graph..
The graph is
y=(x+895.185)*(42.036*sqrt(x+657.509)-1656.4)-42.036*sqrt(x+657.509)*(x+1790.37)+2234.91*x+2.484*10.^6;
I made a code for this like below.
x=(0:0.1:1000);
y=(x+895.185)*(42.036*sqrt(x+657.509)-1656.4)-42.036*sqrt(x+657.509)*(x+1790.37)+2234.91*x+2.484*10.^6;
but I got the error massage...
how can I solve it?
thank you!
0 comentarios
Respuesta aceptada
Image Analyst
el 8 de Ag. de 2016
When you multiply a vector by another vector element by element, you need to use .* instead of * otherwise it tries to do a matrix multiplication. Fixed code:
y=(x+895.185).*(42.036*sqrt(x+657.509)-1656.4)-42.036*sqrt(x+657.509).*(x+1790.37)+2234.91*x+2.484*10.^6;
3 comentarios
Image Analyst
el 8 de Ag. de 2016
No. When you did
x=(0:0.1:1000);
you made a vector. The parentheses were optional and unneeded. You could just have well have done
x = 0 : 0.1 : 1000;
and that would have been a vector too. And of course "sqrt(x+657.509)" is also a vector, and "(x+895.185)" is also a vector, and so is "(x+1790.37)" and "2234.91*x". You do not need a dot if you're multiplying a scalar (single number) times a vector, just when you want to multiply two vectors element by element, and of course they need to be the same length.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!