필터 지우기
필터 지우기

Invalid indexing or function definition

조회 수: 14 (최근 30일)
El Vapor
El Vapor 2020년 7월 1일
댓글: madhan ravi 2020년 7월 1일
Hey guys, I've coded this very simple example of my problem:
syms z(x,i) x i
for i=1:3
h(i) = i+1;
z(x,i) = h(i) + 5;
end
Don't know why, but when running it I get this error:
Error using sym/subsasgn (line 959)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and
function body must be sym expression.
Error in prueba (line 6)
z(x,i) = h(i) + 5;
I've read in this forum and tried different solutions like adding "sym(h(i)", instead of just "h(i)". But it hasn't worked :/ Would appreciate some help. Thank you very much

답변 (1개)

madhan ravi
madhan ravi 2020년 7월 1일
 syms h [1, 5]
 z = h + 5
  댓글 수: 2
El Vapor
El Vapor 2020년 7월 1일
I mean, z should be a function of x too, also I need to place values in it inside a for, that's why my example was:
syms z(x,i) x i
for i=1:3
h(i) = i+1;
z(x,i) = h(i) + 5;
end
h is different for each i, and so it is z(x). However, I am still getting this error
madhan ravi
madhan ravi 2020년 7월 1일
Just show how the expected result should look like.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by