how to handle unknown size of arrey

Actually i am going to use structural data that is very large and i have to use it one by one and i do not know what is its size. so please help me how can i handle it.

3 Comments

What do you mean with 'handle'? What is your input and what is your intended output?
sir i have a acceleration data for a dynamic struture which i have to create an array form for the further analysis.
Have a read here and here. It will greatly improve your chances of getting an answer.

Answers (1)

Use the size function to get the dimensions. There are other functions in and at the end of the size documentation that can provide you with similar results.
To use the results, assuming ‘A’ is your array, to index the the rows:
r_idx = 1:size(A,1);
and the columns:
c_idx = 1:size(A,2);
and other dimensions as necessary.

21 Comments

but here i am not interested to konw the size of the data. my concern is, how can i handle it and write as an array form.
NEL = numel(YourStructure);
Output = cell(size(YourStructure));
for Lidx = 1 : NEL
this_entry = YourStructure(Lidx);
now calculate based on this_entry.AppropriateField
Output{Lidx} = calculated result;
end
The result, Output, will be a cell array the same size as YourStructure.
sir i have a acceleration data for a dynamic struture which i have to create an array form for the further analysis.
acceleration_cell = {YourStructure.NameOfTheAccelarationDataField};
N = ndims(acceleration_cell{1});
acceleration_array = cat(N+1, acceleration_cell{:});
Now if all went well, acceleration_array will be an array with one more dimension than the individual acceleration data. For example if the acceleration data struct fields are 2D then acceleration_array will be 3D, with the third dimension reflecting the linear index into the structure array.
This relies upon the various structure array entries all being the same size. If that is not the case, then you need to tell us how you want the data to be put together into a numeric array.
i have data in axcel form and acceleration in one column and unknown size of row then how will be it work.
readtable() the file, possibly using a Range option to indicate a group of adjacent columns to read.
acce_cell = {acce(:,2)}; %% it was reading data from excel
q = ndims(acce_cell{1});
acce_array = cat(q+1, acce_cell{:});
but it is not working.
Did you readtable or did you xlsread or did you importdata?
I do not understand the problem. Both columns are vectors, and the two together form a matrix.
Please describe in more detail what you want to do.
i want to form a array of second column which have unknown nymbers of rows with a cloumn.
I still do not understand.
Perhaps:
Time = (0:0.005:0.055)'; % Create Vector (Original Not Provided)
Acc = -rand(size(Time)); % Create Vector (Original Not Provided)
A = table(Time,Acc)
C = table((1:size(A,1))', 'VariableNAmes',{'C'}); % Row Numbers
A = [C, A]
producing:
A =
12×3 table
C Time Acc
__ _____ ________
1 0 -0.84193
2 0.005 -0.83292
3 0.01 -0.25644
4 0.015 -0.61346
5 0.02 -0.58225
6 0.025 -0.54074
7 0.03 -0.86994
8 0.035 -0.26478
9 0.04 -0.31807
10 0.045 -0.11921
11 0.05 -0.93983
12 0.055 -0.64555
the time is very large and the acceleration changes from negative to positive also.
This was just an example, since I have no idea what you want.
Is that close to what you want, or do you want something else?
ok sir, i am telling you in details. actually i am working with some structural dynamics model for the evaluation of load due the acceleration from the dynamics data which is very large. for load evaluation i have to multiply this acceleration with global elemental maas so i want the acceleration data in array form.
hope you understand now!!
anothe point i am giving you sir, see i have a vecto size is (m by 1) where m is unkown now i want to create it i an array form.
I am still lost. My background is in electrical engineering, not structural engineering, so none of this is intuitive to me.
I have absolutely no idea what you want to do with the vector and mass multiplication. Is the mass a scalar, vector, or matrix? What are the sizes of each?
mass is a matrix of ( 8 by 8) and i have to multiply acceleration with it for every single acceleration. when i am multiplying with single value than its ok but i use a loop for like
for j=1:1:Ug %% this is acceleration coming from excel
for i=1:ne %%% number of element
Ecc=eval(['Ee',num2str(i)]);
acc=[0.3*Ug(j,1);Ug(j,1);0;Ecc.*(Ug(j,1))';0.3*Ug(j,1);Ug(j,1);0;Ecc.*(Ug(j,1))'];
mas = eval(['m',num2str(i)]); %% calling global elemental mass matrix
eval(['force',num2str(i),'=mas*acc']);
end
end
this is not working with all value in a loop.
As I mentioned, this has gotten from something I am comfortable working with (general MATLAB coding in this instance) to structural engineering that is beyond my expertise.
I am stopping here, intending that someone with relevant expertise continue it.
You will likely need to use a loop to multiply your (8x8) mass matrix by individual single elements of your acceleration vector. What you then do with the result, I have absolutely no idea.
Beyond that, please do not use the eval function! There are much better and more efficient ways of doing what you want.
Do not use importdata. Use readtable

This question is closed.

Asked:

on 2 Feb 2020

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!