Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
how to handle unknown size of arrey
조회 수: 3 (최근 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!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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 (한국어)