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)
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!