フィルターのクリア

Unable to perform assignment because brace indexing is not supported for variables of this type.

100 ビュー (過去 30 日間)
Hi everyone, I am trying to run this code:
clear all
close all
clc
syms x(t) y(t) z(t) A B C D E FF G H I J K LL MM N O P Q R S
eqn1 = diff(x(t),t) == 1/ A * ((B * C - B * x(t))) - (x(t) * D * E - FF*((y(t) * z(t)^2)/(z(t)^2 + G * z(t) + G * H))) / ((1/I) + 1/(J * (((K*(FF* x(t) * D * E - ((y(t) * z(t)^2)/(z(t)^2 + G * z(t) + G*H))))) + LL * (((G * FF * x(t) * D * E/z(t)) - ((y(t) * G * z(t))/(z(t)^2 + G * z(t) + G*H)))) + MM * ((((G * H *FF* x(t) * D * E/z(t)^2) - ((y(t) * G * H)/(z(t)^2 + G * z(t) + G*H))))))) / (K * (FF * x(t) * D * E - ((y(t) * z(t)^2)/(z(t)^2 + G * z(t) + G*H)))));
eqn2 = diff(y(t),t) == (x(t) * D * E - FF*((y(t) * z(t)^2)/(z(t)^2 + G * z(t) + G*H))) / ((1/I) + 1/(J * (((K*(FF* x(t) * D * E - ((y(t) * z(t)^2)/(z(t)^2 + G * z(t) + G * H)) ) + LL * (((G * FF * x(t) * D * E/z(t)) - (( y(t) * G * z(t))/(z(t)^2 + G * z(t) + G*H)))) + MM * ((((G * H * FF * x(t) * D * E / z(t)^2) - ((y(t) * G * H)/(z(t)^2 + G * z(t) + G * H))))))/ (K * (FF * x(t) * D * E - (( y(t) * z(t)^2)/(z(t)^2 + G * z(t) + G * H))))))) - 0.162 * exp(-5153/E) * (((N * (( y(t) * G * H)/(z(t)^2 + G * z(t) + G*H)))/O) - 1)^2 * (P / ((N * (((y(t) * G * H)/(z(t)^2 + G * z(t) + G * H))))) / O));
eqn3 = z(t) + 2 * N - ((y(t) * G * z(t))/(z(t)^2 + G * z(t) + G*H)) - 2 * (( y(t) * G * H)/(z(t)^2 + G * z(t) + G*H)) - ((N * Q * z(t))/(z(t)^2 + Q * z(t) + Q*R)) - 2 * ((N * Q * R)/(z(t)^2 + Q * z(t) + Q*R)) - S/z(t) == 0;
eqns = [eqn1 eqn2 eqn3];
vars = [x(t); y(t); z(t)];
origVars = length(vars);
M = incidenceMatrix(eqns, vars);
[eqns, vars] = reduceDifferentialOrder(eqns, vars);
isLowIndexDAE(eqns,vars);
f = daeFunction(eqns,vars, A, B, C, D, E, FF, G, H, I, J, K, LL, MM, N, O, P, Q, R, S);
A = 1.5e-6;
B = 1.66667e-5;
C = 6.51332e-2;
D = 8.314;
E = 323.15;
FF = 149;
G = 6.24;
H = 5.68e-5;
I = 4.14e-6;
J = 7.25E-2;
K = 2.98e-9;
LL = 2.35e-9;
MM = 1.69e-9;
N = 8;
O = 1.07e-7;
P = 10;
Q = 1.7e-3 ;
R = 6.55e-8;
S = 5.3e-8 ;
F = @(t, Y, YP) f(t, Y, YP, A, B, C, D, E, FF, G, H, I, J, K, LL, MM, N,O, P, Q, R, S);
vars;
y0est = [4.58E-02; 1.58; 1];
yp0est = zeros(3,1);
opt = odeset('RelTol', 10.0^(-7), 'AbsTol' , 10.0^(-7));
[y0, yp0] = decic(F, 0, y0est, [], yp0est, [], opt);
[tSol,ySol] = ode15i(F, [6720, 27840], y0, yp0, opt);
for k = 1:origVars
S{k} = char(vars(k));
end
However, I get the error message:
Unable to perform assignment because brace indexing is not supported for variables of this type.
Error in Example01Sept2018 (line 57)
S{k} = char(vars(k));
The Debugging points me to:
for k = 1:origVars
S{k} = char(vars(k));
end
When I change to:
for k = 1:origVars
S(k) = char(vars(k));
end
I get an error message:
Unable to perform assignment because the left and right sides have a different number of elements.
Error in Example01Sept2018 (line 57)
S(k) = char(vars(k));
What can I do?
  2 件のコメント
NN
NN 2020 年 12 月 12 日
i also got the same error ,
Unable to perform assignment because brace indexing is not supported for variables of this type.
do not know how to solve this.Please help
y=xlsread('DelhiTRAIN2.xlsx');
XTrain=y((1:end),1:5);
YTrain=y((1:end),6);
m = min([XTrain(:)],[],2);
M = max([XTrain(:)],[],2);
idxConstant = M == m;
for i = 1:numel(XTrain)
XTrain{i}(idxConstant,:) = [];
end
Walter Roberson
Walter Roberson 2020 年 12 月 12 日
m = min([XTrain(:)],[],2);
The (:) forces a column vector. Why are you asking for the min() along the second dimension for something that is a column vector? The result is just going to be the same as XTrain(:)
XTrain{i}(idxConstant,:) = [];
The first output of xlsread() is never a cell array, so y() indexed will not be a cell array, so XTrain will not be a cell array, so you should not be assigning into XTrain{i}
What is your purpose in that loop?

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2018 年 9 月 1 日
You have
S = 5.3e-8 ;
but later you want to use S to store the names of the variables. I do not recommend re-using the name of a numeric coefficient for something completely different: it gets too confusing.
But if it is for some reason very important to use the name S in both cases, then you will need to assign something to change S into a cell array, such as
S = cell(origVars, 1);
Or you can skip the initialization and the explicit loop and use
S = arrayfun(@char, vars, 'uniform', 0);
  2 件のコメント
Dursman Mchabe
Dursman Mchabe 2018 年 9 月 1 日
Oops! I forgot to change it to SS, I initially intended to change it to SS. Sorry Walter.
Dursman Mchabe
Dursman Mchabe 2018 年 9 月 1 日
Thanks a lot Walter, the code runs perfect with SS.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by