antonpuz
antonpuz

Reputation: 3316

plotting symfun and a self created function on same graph matlab

i am trying to plot two function in matlab, the first one is of kinf symfun:

p = symfun(0, [m]);
p(m) = p(m)+Ck(k-3)*exp(m*(k-3)*complex(0, 2*pi/25));

here Ck is another symfun and k is a variable i pre-defined.

i want to plot it in the same graph with a function i created using the function mode:

function [x1] = xt_otot_q3( t)...

i cant make the xt_otot_q3 function a symfun because it involves if statements. - i tried to create 2 vectors sampling the two functions and plotting them together with the plot function but for some reason the 'p' function vectors gets preatty grotesque giving me wierd output... - i tried plotting them both using ezplot function but for some reason the sampled vector i got form xt_otot_q3 shows only as a straight line at 0.

any ideas how i should plot them together? to plot the xt_otot_q3 function i must create a vector if i try to plot it directly using ezplot it gives me the following eror:

>> ezplot(xt_otot_q3, [-10 10])
Error using xt_otot_q3 (line 2)
Not enough input arguments.

thanks in advance.

Upvotes: 0

Views: 1090

Answers (1)

chans
chans

Reputation: 497

If I am understanding it properly, you have two functions p, and xt_otot_q3. You want to plot them together.

syms t;
func1 = xt_otot_q3(t);
ezplot(func1, [-10 10]); 
# retain current graph, for new graph
hold on;
# symbolic function p
ezplot(p, [-10 10]); 

I hope it helps.

Upvotes: 0

Related Questions