mesh function and vectors

4 visualizzazioni (ultimi 30 giorni)
BlkHoleSun
BlkHoleSun il 27 Ott 2017
Risposto: Walter Roberson il 27 Ott 2017
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)

Risposta accettata

Walter Roberson
Walter Roberson il 27 Ott 2017
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)

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by