Conversion to double from sym is not possible
Show older comments
close all;
clear all;
clc
L = 0.05;
% L = 0.32;
V = 76;
Cn = he(0,2000,10^4,76);
syms k
f = 0:2000:10^4;
Km = (5.92/0.004)^2;
Ko = ((2*pi)/1.6)^2;
z = pi*(L).*sqrt((k^2+((f.^2)./(V^2))));
j = besselj(1,z);
we1 = ((j.^2)./(k^2+((f.^2)./(V^2)))).*((exp(-(k^2+((f.^2)./(V^2)))./Km))./(((k^2+((f.^2)./(V^2)))+Ko).^(11/6)));
we2 = (0.033.*Cn.*(L^2))./(4*(V^2));
we3 = int(we1, k, 0, inf);
Pw = (f.*We);
semilogx(f, Pw)
hold on
grid
Error using ==> semilogx
conversion to double from sym is not possible
Answers (1)
John D'Errico
on 20 Nov 2018
Edited: John D'Errico
on 20 Nov 2018
0 votes
Do we need to guess what the function he does? If I assume it returns some arbitrary numeric value, then look at what you are doing.
You declare a symbolic parameter k, which enters into all of your computations. As well, you have a vector f. If I can presume that Pw is a function of k, then we have a vector value function, Pw, so a function of k at every value of f.
Then you try to plot Pw versus f.
What value should be plotted? How can this possibly be plotted as a function dependent on f? You cannot use these tools as you are trying to use them. Sorry, but it makes no sense.
What else have you done that makes no sense at all? Lets see. You define we1, then we2, then we3. In we3, you integrate out k. But you never use we1, we2, or we3. Instead, you define Pw in terms of a variable named we, which you never defined at all.
What else? Lets see, I see that you use the variable j in we1, in this sub-expression:
(j.^2)
Since you never define j, is j intended to be sqrt(-1), as it is by default? Of course, then why not just use -1, since you are squaring it? Or is j some number that we are not told about? That might be because there are lots of squirrely things done in this code.
How do I know that there are many issues and undefined variables? I know because your code could never actually run and produce the error message you claim it does. You start out with a clear all, but then you used the undefined variable we. And semilogx returned an error message that indicates we does in fact exist. So what you actually did and what you have shown us are completely inconsistent.
I suppose I might try to debug your code more, but there are too many problems in it already and uncertainties to even try.
My only suggestion is that you learn to be more careful in your coding practices. I think you are defining variables in your workspace, writing code, then using other variables forgetting that you changed a variable name, and you are confused. Then you get a strange error message that you don't understand, so you gave up. Instead, Work more slowly! Be careful about what you have. Test each line as you write it. Verify that it did what you might expect. Only then go on to write a new line of code. Think about what you are doing, clearly. Otherwise, you get random meaningless garbage, basically what I see here.
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!