Hi I'm kinda new to Matlab Wot i'm trying to do is draw a Bode plot without using the inbuilt 'bode' function. i tried using logspace command for the purpose but all in vain can anyone help??? Here is the code i had written a=[0 0 25]; b=[1 4 25]; w=logspace(-1,2) hold on w1=0.1:100; for i=1:100 x=polyval(a,j*w1(i)); y=polyval(b,j*w1(i)); z=x/y; b=abs(z); plot(20*log10(B),w(i),'+') hold on end pls help thx a lot
Not sure about the bode mechanics, but I can see MatLab coding issues. You cant do logs for negative numbers is your logspace issue. No numbers to a power cangive you a negative number using a typical log base of 10. w1 id forming a sequency of 0.1 1.1 2.1 3.1 ... 99.1 and never reaches 100. You use B in theplot, it should be b. You should not use the plot inside of a for next loop. You should use MatLab vector abilities to do all you looping. i.e. w=logspace(-1,2) <-- what sequence are u trying to make? i=[1:100] w1=[0.1:100] <--- what kind of numeric sequenceare you trying tomake here??? x=polyval(a,j*w1); <-- no subscript, and it will make x into a vector y=polyval(b,j*w1); <-- same here z=x./y; <-- add the . to the / to make it a memberwise division for vectors b=abs(z); plot(20*log10(B),w,'+") <---Need to know about w before I can fix this.
thx brandon for ur reply Wot i'm trying to do is plot 20*log10(B) against w where i need the magnitude in db ie 20*log10(B) on a linear scale while i want w to vary logarithmically so thats why i used logspace w =(-1,2) ie w varying from 0.1 to 100 but logarithmically i hope u r getting wot i'm trying to convey i'll try n attach a figure to explain
I gotcha.. Check out the semilog function rather than plot. Its a plot which turns 1 axis into a log scale all by itself, either semilogx or semilogy. You don't need to do anything, you just need to define your overall frequency range and it will scale it for you by orders of magnitude.
Ok sorry for interruption but can u plz tell me what this MATLAB all abt?.I heared abt it,that it needs some codes to work on Mathematics eqs and graphs but what kinda language is this,,and can I find any tutorial on it??...Ok but I work with MathEq and MathType and it do not need any codings.
Matlab is a bit like Mathematica and Maple. In my opinion, Maple is a cross between Matlab and Mathematica. Just like Mathematica, u can create Matlab programs to handle things that are not built in..ie. to perform more complicated functions etc. There are many tutorials on the web..just google it... PS. what's MathType and MathEq?
MatLab is also built around C++ and it has its own C compile built right into the program. You can take wnything you write in MatLab and convert it into an exe for calculations. Its great for DSP, Control Systems, statistics, and all just about anything mathmatic related you can think of. You can redefine tons of functions andf actually make your own which is where a lot of the coding comes in. Using MatLab I was able to make a program that would turn a text ascii file into an AM modulated waveform and hide it inside of a .wav file. You late could take the .wav file, filter out the music and reconstruct the text. If you can get a chance, check it out.