mesh function and vectors

2 次查看(过去 30 天)
Working on problem pasted below. Currently, I'm having a problem with my 'z' equation. It seems as though my matrices are of the same size, but there's something I'm missing. I've added my incomplete code so far as well as the question.
%Create hundered-element vectors
r=linspace(0,1,100);
rho=linspace(0,2*pi,100);
z(r,phi)=J*((3.8316*r)*cos(rho))
%Cartesian grid nodes
x=r.*cos(rho);
y=r.*sin(rho);
J=besselj(1,x);
%Make values of 'z' NaN
find(z<-0.2)=NaN
find(z>0.2)=NaN
%Using Mesh function to show damage
mesh(x,y,z)

采纳的回答

Walter Roberson
Walter Roberson 2017-10-27
You have
z(r,phi)=J*((3.8316*r)*cos(rho))
This is not valid. r on the left side is a vector of floating point numbers, but those are not valid indices. You have not defined phi. If we assume that this should be a symbolic function definition, that you previously did a "syms phi", then you have the problem that you defined r numerically and you cannot use numeric variables when defining a symbolic function.
I suspect you want
syms R RHO
z(R, RHO) = J*((3.8316*R)*cos(RHO))
or
z = @(r, rho) J*((3.8316*r)*cos(rho))
On the other hand if you review back to the question you will find that J subscript 1 is the notation used for the Bessel function of the first kind. This is a function call, not a constant to be multiplied.
syms x
J1(x) = besselj(1,x)
or
J1 = @(x) besselj(1,x)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by