Info
この質問は閉じられています。 編集または回答するには再度開いてください。
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
how to handle unknown size of arrey
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
Rik
2020 年 2 月 3 日
What do you mean with 'handle'? What is your input and what is your intended output?
Chaudhary P Patel
2020 年 2 月 3 日
sir i have a acceleration data for a dynamic struture which i have to create an array form for the further analysis.
Rik
2020 年 2 月 3 日
この質問は閉じられています。
回答 (1 件)
Star Strider
2020 年 2 月 2 日
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 件のコメント
Chaudhary P Patel
2020 年 2 月 3 日
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.
Walter Roberson
2020 年 2 月 3 日
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.
Chaudhary P Patel
2020 年 2 月 3 日
sir i have a acceleration data for a dynamic struture which i have to create an array form for the further analysis.
Walter Roberson
2020 年 2 月 3 日
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.
Chaudhary P Patel
2020 年 2 月 3 日
i have data in axcel form and acceleration in one column and unknown size of row then how will be it work.
Walter Roberson
2020 年 2 月 3 日
readtable() the file, possibly using a Range option to indicate a group of adjacent columns to read.
Chaudhary P Patel
2020 年 2 月 3 日
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.
Star Strider
2020 年 2 月 3 日
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.
Chaudhary P Patel
2020 年 2 月 3 日
i want to form a array of second column which have unknown nymbers of rows with a cloumn.
Star Strider
2020 年 2 月 3 日
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
Chaudhary P Patel
2020 年 2 月 3 日
the time is very large and the acceleration changes from negative to positive also.
Star Strider
2020 年 2 月 3 日
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?
Chaudhary P Patel
2020 年 2 月 3 日
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.
Chaudhary P Patel
2020 年 2 月 3 日
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.
Star Strider
2020 年 2 月 3 日
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?
Chaudhary P Patel
2020 年 2 月 3 日
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.
Star Strider
2020 年 2 月 3 日
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.
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)