フィルターのクリア

getting time series data from simspace model

2 ビュー (過去 30 日間)
Ala'a Alshubbak
Ala'a Alshubbak 2023 年 2 月 25 日
コメント済み: Ala'a Alshubbak 2023 年 2 月 28 日
I am running a model of an excavator built on simspace simulation. I got my data from the model as a time series.
I try to enter each data independently to have a matrix. for example at time =12 . I want a matrix that has information on position x and z
I wrote my code as function named (create_NewPinLoc_XZ) to take the results from simulation (simOut) and an iteration time (I) and give me an out put of structure variable ( pin_struc) . although my script works probably on all-time slots, it fails on time =xx.8 and xx.3
for example, at time =18.3 or 18.8 .. the output structure called (pin_struc) gives an empty value.
starting from 15.8 ,and above , the results become empty structure for time= xx.3 and xx.8 only.
it looks strange , and i don't know what is exactly the issue.
here is my function script.
function pin_struc= create_NewPinLoc_XZ(simOut,I)
%%%%%%%%% simout contains a structure for all pin location as time serise
%%%%%%%%% I is a time between 0:0.1:31
%time vector
time=simOut.excavator_frames2.Chassis.A1.Time;
%chassis pins
A1=simOut.excavator_frames2.Chassis.A1;
A2=simOut.excavator_frames2.Chassis.A2;
%chassis matrix
A1_info=A1.data;
A2_info=A2.data;
%boom pins
B1= simOut.excavator_frames2.Boom.B1;
B2= simOut.excavator_frames2.Boom.B2;
B3= simOut.excavator_frames2.Boom.B3;
%boom matrix
B1_info=B1.data;
B2_info=B2.data;
B3_info=B3.data;
% stick pins
C1= simOut.excavator_frames2.Stick.C1;
C2= simOut.excavator_frames2.Stick.C2;
C3= simOut.excavator_frames2.Stick.C3;
C4= simOut.excavator_frames2.Stick.C4;
%stick matrix
C1_info=C1.data;
C2_info=C2.data;
C3_info=C3.data;
C4_info=C4.data;
% bucket
D1= simOut.excavator_frames2.Bucket.D1;
D2= simOut.excavator_frames2.Bucket.D2;
D3= simOut.excavator_frames2.Bucket.D3;
%BUCKET MATRIX
D1_info=D1.data;
D2_info=D2.data;
D3_info=D3.data;
%linkage
E1= simOut.excavator_frames2.Linkage.E1;
%LINKAGE MATRIX
E1_info=E1.data;
%create a data for a table for certain i time iteration
%data only for x-axis and z-axis [1 3]
%chassis @I itertion
A1_pin=A1_info(time==I,[1 3]);
A2_pin=A2_info(time==I,[1 3]);
%boom @I itertion
B1_pin=B1_info(time==I,[1 3]);
B2_pin=B2_info(time==I,[1 3]);
B3_pin=B3_info(time==I,[1 3]);
%stick @I itertion
C1_pin=C1_info(time==I,[1 3]);
C2_pin=C2_info(time==I,[1 3]);
C3_pin=C3_info(time==I,[1 3]);
C4_pin=C4_info(time==I,[1 3]);
%BUCKET
D1_pin=D1_info(time==I,[1 3]);
D2_pin=D2_info(time==I,[1 3]);
D3_pin=D3_info(time==I,[1 3]);
%LINKAGE
E1_pin=E1_info(time==I,[1 3]);
%THE GLOBAL NEW STRUCTURE
fprintf('find pins location on only x and z axies \n')
%Create new structure with only one info for one pins situation
%chassis
ExcvGlobal_new_xz.Chassis.ToBoom= A1_pin;
ExcvGlobal_new_xz.Chassis.ToBoomCyl= A2_pin;
%boom
ExcvGlobal_new_xz.Boom.ToBoomCyl=B1_pin;
ExcvGlobal_new_xz.Boom.ToStickCyl=B2_pin;
ExcvGlobal_new_xz.Boom.ToStick=B3_pin;
%stick
ExcvGlobal_new_xz.Stick.ToStickCyl=C1_pin;
ExcvGlobal_new_xz.Stick.ToBucketCyl=C2_pin;
ExcvGlobal_new_xz.Stick.ToBucketLinkage=C3_pin;
ExcvGlobal_new_xz.Stick.ToBucket=C4_pin;
%Bucket
ExcvGlobal_new_xz.Bucket.ToBucketLinkage=D1_pin;
ExcvGlobal_new_xz.Bucket.ToCuttingEdge=D2_pin;
ExcvGlobal_new_xz.Bucket.ToCG=D3_pin;
%Linkage
ExcvGlobal_new_xz.Linkage.ToBucketCyl=E1_pin;
pin_struc =ExcvGlobal_new_xz;
end
Can you please suggest something to develop my code and remove such a problem. the original simOut has values from time slot 0 till 31 with a step of 0.1
  2 件のコメント
Ala'a Alshubbak
Ala'a Alshubbak 2023 年 2 月 27 日
I can explain my issue in more clear words:
I have a time series data represneted by simOut. I want to enter some values inside it according to the time.
I use this instruction to enter the data of column 1 and 3 according to time =I
A1_pin=A1_info(time==I,[1 3]);
unfortunatily this instruction works with some values of I and give an empty array with another values
the error will be because of having an empty matrix , which is totally wrong as there is data within the original simOut file.
for example on simOut @ time= 21.8 , the A1.data= [0.00266849360760513 0.00328331387131686 1.96413626062420]
but when try to access it using the above instruction it gives me this
A1_pin =
0×2 empty double matrix
Ala'a Alshubbak
Ala'a Alshubbak 2023 年 2 月 28 日
I solved it . thank you.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeApplications についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by