How to use indexing format inside symsum function

1 visualizzazione (ultimi 30 giorni)
clc;
close all;
clear all;
N=2;alpha=0.5
t=zeros(1,N)
l=1:N;
t(l)=solve(chebyshevT(N,2*x-1),x);
syms m
L=symsum(t(m),m,1,2)
  2 Commenti
SUMIT
SUMIT il 1 Lug 2023
After running the program i got
''Invalid indexing or function definition. When defining a function, ensure that the arguments are symbolic variables and the body of the function is a SYM expression. When indexing, the
input must be numeric, logical, or ':'.''
please help me out
Paul
Paul il 1 Lug 2023
Hi Sumit,
The code results in a different error because x is not defined. Is x supposed to be symbolic variable? What is the function chebyshev? It might be helpful if to explain what the code is trying to accomplish.
N=2;alpha=0.5;
t=zeros(1,N);
l=1:N;
t(l)=solve(chebyshevT(N,2*x-1),x);
Unrecognized function or variable 'x'.
syms m
L=symsum(t(m),m,1,2)

Accedi per commentare.

Risposte (2)

Steven Lord
Steven Lord il 1 Lug 2023
If you want to sum the elements of a symbolic array, just use sum.
syms x
f = x.^(0:5)
f = 
s = sum(f)
s = 

Walter Roberson
Walter Roberson il 1 Lug 2023
It is never possible to index by a symbolic variable at the MATLAB level. (There are some cases in the internal symbolic computing engine where indexing by a symbolic variable is possible.)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by