How to simply multiply a symbolic variable into a matrix?

I have a matrix of numbers that is calculated using a formula that includes a symbolic variable.
A(n+1,m+1) = u*Bnm*A(n,m+1) - Bnm_over_nm1m*Anm2m;
u is the only symbolic variable present here. I get the expected 'can't convert syms to double' error here. Right now I have everything implemented as if u were actually a number (aside from its initial definition). What could I do to make this formula possible with minimal architecture changes?
I'm aware of symbolic arrays, but it's important that I'm able to perform calculations with more arrays later on and the A matrix ends up being lower triangular.
Currently to get this running I'm just substituting a made up value for u. I'd like to be able to see where u is being used in further calculations.

3 Comments

What do you finally want to do with this u variable ? Solve for it in some kind of equation ?
I don't need to do anything with the u variable. It would be an input that contributes to the final result, but I don't need to know the value of that input for my purposes at the moment.
Somewhere in your computations, you will either define a value for u or you will have u as an unknown.
In both cases, you can make a function with "u" as input parameter and derive A (and maybe other variables) as outputs from this function.

Sign in to comment.

 Accepted Answer

What ended up being a good fit for me was defining A with A = sym(zeros(n,m)); I'd stepped away from matlab for a bit and am clearly a little rusty...ugh. I just needed most of A to be defined as zero from the start and not the symbolic Anm coefficients sym(n,m) would give.

More Answers (1)

I'm pretty sure that if u is to be symbolic then so must be A (unless you make A into a cell array, which is probably not the way to go). What's the objection making A symbolic?

Categories

Products

Release

R2023a

Asked:

on 22 Nov 2023

Answered:

on 27 Nov 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!