I am unsure of how I am getting this error

1 visualización (últimos 30 días)
Cameron Paterson
Cameron Paterson el 27 de Oct. de 2021
Respondida: David Hill el 27 de Oct. de 2021
r=linspace(0.001,1,1000);
s=0.75.*((r.^3)/(exp(1)^(.75.*r)));
subplot(2,2,1)
plot(r,s)
xlabel('x')
ylabel('y(x)')
axis([min(r) max(r) min(s) max(s)])
grid on
subplot(2,2,2)
semilogy(r,s)
xlabel('x')
ylabel('y(x)')
axis([min(r) max(r) min(s) max(s)])
grid on
subplot(2,2,3)
semilogx(r,s)
xlabel('x')
ylabel('y(x)')
axis([min(r) max(r) min(s) max(s)])
grid on
subplot(2,2,4)
loglog(r,s)
xlabel('x')
ylabel('y(x)')
axis([min(r) max(r) min(s) max(s)])
grid on
Error using ^ (line 51)
Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a
scalar. To perform elementwise matrix powers, use '.^'.
Error in HW8P3 (line 2)
s=0.75.*((r.^3)/(exp(1)^(.75.*r)));
  1 comentario
Stephen23
Stephen23 el 27 de Oct. de 2021
Editada: Stephen23 el 27 de Oct. de 2021
"I am unsure of how I am getting this error"
Did you read the last part of the error message?: To perform elementwise matrix powers, use '.^'.
You probably need to use array operations, not matrix operations:

Iniciar sesión para comentar.

Respuestas (1)

David Hill
David Hill el 27 de Oct. de 2021
r=linspace(0.001,1,1000);
s=0.75*((r.^3)./(exp(1).^(.75*r)));%error is here (multiplying by scalar does not need .*, but you need elementwise operations for matrix operations is needed)
subplot(2,2,1)
plot(r,s)
xlabel('x')
ylabel('y(x)')
axis([min(r) max(r) min(s) max(s)])
grid on
subplot(2,2,2)
semilogy(r,s)
xlabel('x')
ylabel('y(x)')
axis([min(r) max(r) min(s) max(s)])
grid on
subplot(2,2,3)
semilogx(r,s)
xlabel('x')
ylabel('y(x)')
axis([min(r) max(r) min(s) max(s)])
grid on
subplot(2,2,4)
loglog(r,s)
xlabel('x')
ylabel('y(x)')
axis([min(r) max(r) min(s) max(s)])
grid on

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by