symbolic-math

How to have square wave in Matlab symbolic equation

為{幸葍}努か 提交于 2019-11-29 12:21:43
My project require me to use Matlab to create a symbolic equation with square wave inside. I tried to write it like this but to no avail: syms t; a=square(t); Input arguments must be 'double'. What can i do to solve this problem? Thanks in advance for the helps offered. here are a couple of general options using floor and sign functions: f=@(A,T,x0,x) A*sign(sin((2*pi*(x-x0))/T)); f=@(A,T,x0,x) A*(-1).^(floor(2*(x-x0)/T)); So for example using the floor function: syms x sqr=2*floor(x)-floor(2*x)+1; ezplot(sqr, [-2, 2]) rayryeng Here is something to get you started. Recall that we can express a

Constructing piecewise symbolic function in Matlab

旧城冷巷雨未停 提交于 2019-11-29 01:57:13
I am trying to generate a piecewise symbolic function in Matlab. The reason it has to be symbolic is I want to be able to integrate/differentiate the function afterwards and/or insert actual values. I have the following function: x^3/6 -> 0 < x <= 1 (1/6)*(-3*x^3+12*x^2-12x+4) -> 1 < x <= 2 (1/6)*(3*x^3-24*x^2+60x-44) -> 2 < x <= 3 (1/6)*(4-x)^3 -> 3 < x <= 4 0 -> otherwise For example, I want to put this function in a variable (let's say f) and then call int(diff(f, 1)^2, x, 0, 4) % numbers could be different and get the (scalar) result 2/3. I tried various things, involving the piecewise()

What is symbolic computation?

拜拜、爱过 提交于 2019-11-29 00:40:01
问题 According to wiki: In mathematics and computer science, computer algebra, also called symbolic computation or algebraic computation is a scientific area that refers to the study and development of algorithms and software for manipulating mathematical expressions and other mathematical objects Does symbolic computation focus on symbol manipulation and computation? Lisp program is written in the form of an AST with atoms as leaves. Lisp is said to be language for symbolic computing. Does it

Function for polynomials of arbitrary order (symbolic method preferred)

≯℡__Kan透↙ 提交于 2019-11-28 12:26:00
I've found polynomial coefficients from my data: R <- c(0.256,0.512,0.768,1.024,1.28,1.437,1.594,1.72,1.846,1.972,2.098,2.4029) Ic <- c(1.78,1.71,1.57,1.44,1.25,1.02,0.87,0.68,0.54,0.38,0.26,0.17) NN <- 3 ft <- lm(Ic ~ poly(R, NN, raw = TRUE)) pc <- coef(ft) So I can create a polynomial function: f1 <- function(x) pc[1] + pc[2] * x + pc[3] * x ^ 2 + pc[4] * x ^ 3 And for example, take a derivative: g1 <- Deriv(f1) How to create a universal function so that it doesn't have to be rewritten for every new polynomial degree NN ? My original answer may not be what you really want, as it was

Matrix with symbolic math gives a symbolic answer, not a numeric one

点点圈 提交于 2019-11-28 02:23:57
Consider the following matrix Ja(t1, t2, t3, t4, t5, t6) = [ (sin(t5)*(cos(t3)*cos(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)) - sin(t3)*sin(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/5 - sin(t1)/100 - (219*sin(t1)*sin(t2))/1000 - (19*cos(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)))/100 - (21*cos(t3)*cos(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)))/1000 + (21*sin(t3)*sin(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)))/1000, (219*cos(t1)*cos(t2))/1000 + (sin(t5)*(cos(t3)*cos(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)) - sin(t3)*sin(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/5 - (19*cos(t3)*(cos(t1)*sin(t2) + cos(t2)

Matrix of symbolic functions

我的未来我决定 提交于 2019-11-27 08:25:06
问题 I would like to define a matrix of symbolic functions (not variables) in Matlab. In the workspace I would like it to be an element of class symfun of size N-by-M (where N and M are positive integers). 回答1: You can't create a matrix of symfun class elements (possibly for the same reason that one can't create a matrix of function handles), but you can create a symbolic function that returns a matrix of symbolic expressions: syms x y z; Afun = symfun([x+y y-z;y/x z-1],[x y z]) B = Afun(sym(pi)

Convert output from symbolic math (sym) to float

假装没事ソ 提交于 2019-11-27 05:41:32
My question is similar to this question but I believe it to be more general. I use Matlab's symbolic math toolbox to solve an equation: MAZ = 0.5; MAU = 1.0; XI = 1.0; ALPHA = 2.0; DRG = 0.5; SRG = 1.0; PHI = 1 / (2 * MAU); syms L; f = 1 - DRG - sqrt(1 + (ALPHA * XI - L / (2 * XI * PHI) ) ^ 2 ) / ... sqrt(1 + (ALPHA * XI) ^ 2) + L / (4 * PHI * SRG * sqrt(1 + (ALPHA * XI)^2)); a = solve(f,L,'Real',true); The answer is: a = 5^(1/2)/3 + (10*((4*5^(1/2))/25 + 6/25)^(1/2))/3 + 8/3 5^(1/2)/3 - (10*((4*5^(1/2))/25 + 6/25)^(1/2))/3 + 8/3 How do I automatically convert these expressions for a - which

Matrix with symbolic math gives a symbolic answer, not a numeric one

做~自己de王妃 提交于 2019-11-26 23:46:21
问题 Consider the following matrix Ja(t1, t2, t3, t4, t5, t6) = [ (sin(t5)*(cos(t3)*cos(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)) - sin(t3)*sin(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/5 - sin(t1)/100 - (219*sin(t1)*sin(t2))/1000 - (19*cos(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)))/100 - (21*cos(t3)*cos(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)))/1000 + (21*sin(t3)*sin(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)))/1000, (219*cos(t1)*cos(t2))/1000 + (sin(t5)*(cos(t3)*cos(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)

Convert output from symbolic math (sym) to float

让人想犯罪 __ 提交于 2019-11-26 11:40:29
问题 My question is similar to this question but I believe it to be more general. I use Matlab\'s symbolic math toolbox to solve an equation: MAZ = 0.5; MAU = 1.0; XI = 1.0; ALPHA = 2.0; DRG = 0.5; SRG = 1.0; PHI = 1 / (2 * MAU); syms L; f = 1 - DRG - sqrt(1 + (ALPHA * XI - L / (2 * XI * PHI) ) ^ 2 ) / ... sqrt(1 + (ALPHA * XI) ^ 2) + L / (4 * PHI * SRG * sqrt(1 + (ALPHA * XI)^2)); a = solve(f,L,\'Real\',true); The answer is: a = 5^(1/2)/3 + (10*((4*5^(1/2))/25 + 6/25)^(1/2))/3 + 8/3 5^(1/2)/3 -