MATLAB Trigonometry Find Field [closed] - matlab

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have this trigonometric equation;
cos(2*pi*50*t)+cos(2*pi*100*t)
I want to graphic of equation and I want to find field for a period. How can I do?

Graph:
>> f = #(t) cos(2*pi*50*t) + cos(2*pi*100*t);
>> x = linspace(0, 1/50, 100);
>> y = f(x);
>> plot(x,y)
Area over 1 period:
>> integral(f, 0, 1/50)
or just do it manually:
∫ ( cos(2π·50t) + cos(2π·100t) ) dt =
-1/2π·( 1/50·sin(2π·50t) + 1/100·sin(2π·100t) )
which, evaluated between 0 and 1/50, equals 0.

Related

can someone help me with a MATLAB function that changes the color space from RBG to ych1tch2? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I need to write a MATLAB function that coverts from RBG to ych1ych2.
Y = 0.299\*R + 0.587\*G +0.114\*B
Ch1 = R - (G+B)/2
Ch2 = (√(3)/2) \* (B-G)
To convert RGB to the luma, chroma cyan-red, chroma green-blue system of Carron (YCh1Ch2), the conversion matrix you need is
rgb2ych1ch2 = [ 0.299 0.587 0.114 ; 1 -0.5 -0.5 ; 0 -sqrt(3)/2 sqrt(3)/2 ];
(This is just the three equations you present converted directly to matrix form.)
You can then convert by multiplying this matrix with your rgb values:
ych1ch2 = rgb2ych1ch2 * rgb;

Plotting a function [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I have a function (the hill function) when X and K are the same (x==k) the output should be 0.5, when I test the function it gives a result of 0.5, when I try to plot it, I do not get 0.5 for my Y. Can anyone explain what I am doing wrong?
n = 1;
k = 1;
x = [0:0.01:2].';
y = (x.^n)/((x.^n)+(k.^n));
plot(x,y);
n = 1;
k = 1;
x = [0:0.01:2].';
y = (x.^n)./((x.^n)+(k.^n));
plot(x,y);
You missed a dot before the division.

Unconstrained Optimization [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
function f = objfun(x)
f = exp(x(1)) * (4*x(1)^2 + 2*x(2)^2 + 4*x(1)*x(2) + 2*x(2) + 1);
x0=[-1,1];
options = optimoptions(#fminunc,'Algorithm','quasi-newton');
[x,fval,exitflag,output] = fminunc(#objfun,x0,options);
x,fval,exitflag,output
end
Can you please help me in running the code?
Convert f to a function handle as
fun = #(x) exp(x(1)) * (4*x(1)^2 + 2*x(2)^2 + 4*x(1)*x(2) + 2*x(2) + 1);
then call fminunc with
[x,fval,exitflag,output] = fminunc(fun,x0,options);
As a side note, don't ever call fminunc from within the objective function.

How to smoothly connect two signals in matlab [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need to generate two signals which in the end I want to connect. The problem is that the end condition of the 1st signal can be quite different compared to the initial conditions in my 2nd signal. Subsequently it can result in a sudden and unrealistic jump in my final signal. Final signal is the 2 connected signals.
How could I smooth the connection in my final signal?
Thanks!
What about some sort of cross-fading:
S1 = rand(1000,1);
S2 = rand(1000,1) + 1;
%\\ cross-fade over last 200 elements
n = 200;
W = linspace(1,0,n)'; %'
S1(end-n+1:end) = S1(end-n+1:end).*W;
S2(1:n) = S2(1:n).*(1-W);
S12 = zeros(size(S1,1) + size(S2,1) - n, 1);
S12(1:size(S1,1)) = S1;
S12(end-size(S1,1)+1:end) = S12(end-size(S1,1)+1:end) + S2;
This was using a linear weighting for the fading, you might choose something else but I think this will sort of work.

Non changing vector components within a For Loop [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Given the following code:
t = -5:.1:5;
w = pi;
x = zeros(101,1);
Xt = zeros(101,1);
for i = 1 : 101;
x = exp((-3*t)+(-1i*w*t));
Xt = trapz(t, x);
end
disp (length(x))
disp (length(Xt))
disp (Xt)
The values of Xt do not change, which is a problem.
How should this be coded in order for Xt to change when x is changed?
Side note:
Xt(i) = trapz(t,x);
Reduces the vector from length 101 to length 1 and therefore cannot be used.
i am not sure if this is what you wanted. anyways while working on imaginary numbers it is always a good idea to not use i and j as common variables, just to avoid confusion (IMO)
xt = zeros(101,1);
x = exp((-3.*t)+(-1i*w.*t));
for k=2:101
xt(k)=trapz(t(1:k),x(1:k));
end