Showing posts with label matlab. Show all posts
Showing posts with label matlab. Show all posts

October 29, 2010

matlab syms

>>syms x
>>syms y
>> y=diff(0.25*3^x*exp(-3.56*x*(1-x)))


y =
(3^x*exp((89*x*(x - 1))/25)*((178*x)/25 - 89/25))/4 + (3^x*exp((89*x*(x - 1))/25)*log(3))/4


>> solve('-(178*x)/25 + 89/25-log(3)=0','x')

ans = 1/2 - (25*log(3))/178


>> x=1/2 - (25*log(3))/178

x = 0.3457



***OR***

>> solve('y=0','y','x')

% if x has only one solution, the value can be seen from the "Workspace"
% However, if it has more than one solution, i still do not know how to look into % the construction of syms......

matlab log

log: Natural logarithm
Syntax: Y = log(X)
Description:
The log function operates element-wise on arrays. Its domain includes
complex and negative numbers, which may lead to unexpected results if
used unintentionally.
Y = log(X) returns the natural logarithm of the elements of X. For
complex or negative , where , the complex logarithm is returned.
log(z) = log(abs(z)) + i*atan2(y,x)
Examples
The statement abs(log(-1)) is a clever way to generate .
ans =
3.1416

October 21, 2010

some commands for matlab

matrix functions

 INV    Matrix inverse.
    INV(X) is the inverse of the square matrix X.
    A warning message is printed if X is badly scaled or
    nearly singular.

 .' Transpose.
    X.' is the non-conjugate transpose.
    B = TRANSPOSE(A) is called for the syntax A.' when A is an object.

 SQUEEZE Remove singleton dimensions.
    B = SQUEEZE(A) returns an array B with the same elements as
    A but with all the singleton dimensions removed.  A singleton
    is a dimension such that size(A,dim)==1.  2-D arrays are
    unaffected by squeeze so that row vectors remain rows.
    For example,   squeeze(rand(2,1,3))    is 2-by-3.

Especially, for a 3-dimension matrix, for the command "matri = original_matrix(1,:,:)", the resulting matrix matri is still a 3-D matrix whose 1st dimension is just 1.

==========

for plotting, this example will explain the most frequently used commands:

x = -pi:.1:pi;
y = sin(x);
plot(x,y);
set(gca,'XTick',-pi:pi/2:pi);
set(gca,'XTickLabel',{'-pi','-pi/2','0','pi/2','pi'});
xlabel('-\pi \leq \Theta \leq \pi');
ylabel('sin(\Theta)');
title('Plot of sin(\Theta)');
AXIS([XMIN XMAX YMIN YMAX])
XLIM([XMIN XMAX])
YLIM([YMIN YMAX])

Days of our lives

Daisypath Anniversary tickers