フィルターのクリア

vector notation with data from struct array

2 ビュー (過去 30 日間)
Benjamin Pommer
Benjamin Pommer 2022 年 3 月 21 日
編集済み: Matt J 2022 年 3 月 22 日
I have the following problem: I want to operate with variables from my workspace which I saved in a struct array. This will be the argument for a self defined function which you can see in the following:
t_abtast = 2;
data = load('GMapsRoute02182022095722SimulationRun.mat')
v = data.GMapsRoute02182022095722SimulationRun.velocity_kmh(1:10:end)';
a = data.GMapsRoute02182022095722SimulationRun.acc(1:10:end)';
t = data.GMapsRoute02182022095722SimulationRun.t(1:10:end);
E = data.GMapsRoute02182022095722SimulationRun.energy(1:10:end)';
v = v(~isnan(v));
a = a(~isnan(a));
E = E(~isnan(E));
v = smooth(v);
a = smooth(a);
E = smooth(E);
v = v(1:t_abtast:end);
a = a(1:t_abtast:end);
t = t(1:t_abtast:end);
E = E(1:t_abtast:end);
t_delta = t(2)-t(1);
P = [0, diff(E)/t_delta];
adot = [0, diff(a)/t_delta];
[A,B,X,Y,y,res,x_vec,x_pred,u_pred] = DMDc1(5,10,4,v,a,adot,P);
...
I get this error message:
Error using horzcat
Dimensions of arrays
being concatenated are
not consistent.
Error in DMD_Prediction
(line 42)
P = [0
diff(E)/t_delta];
Before I loaded the variables with the evalin function and there was not problem.
load('GMapsRoute02182022095722SimulationRun.mat')
v = evalin('base','GMapsRoute02182022095722SimulationRun.velocity_kmh');
a = evalin('base','GMapsRoute02182022095722SimulationRun.acc');
t = evalin('base','GMapsRoute02182022095722SimulationRun.t');
E = evalin('base','GMapsRoute02182022095722SimulationRun.energy');
When I change the notation from "," to ";", I receive the following error:
Unable to perform assignment because the size of the left side is 4-by-239
and the size of the right side is 972-by-0.
Error in DMDc1 (line 71)
X((ii-1)*states+1:ii*states,:) = y(:,ii:end-n+ii);
Error in DMD_Prediction (line 47)
[A,B,X,Y,y,res,x_vec,x_pred,u_pred] = DMDc1(5,10,4,v,a,adot,P);
So, this rewriting leads to problem later in the code.

採用された回答

Matt J
Matt J 2022 年 3 月 22 日
Error in DMD_Prediction (line 42)
P = [0
diff(E)/t_delta];
In all likelihood diff(E) is not a row vector. THat should be easy to check.
  2 件のコメント
benjamin pommer
benjamin pommer 2022 年 3 月 22 日
Thank you. I could solve it
Matt J
Matt J 2022 年 3 月 22 日
編集済み: Matt J 2022 年 3 月 22 日
You're welcome, but please Accept-click the answer if it resolved your question.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by