clear all; clc;clf;
for k=1:5;
cos_el=R*cos(Elev);
asin_x=asin(cos_el);
cos_y=cos(asin_x);
vtec=stec.*(cos_y);
gistm =[ut, vtec];
TV_A{k}=ut;
L(k)=length(ut);
end
Following my coding. So i have 5 ut data and 5 vtec data. I need to find highest length of ut seems i have 5 ut data. then the highest length of ut data need to be in the first column in a new .mat form and following up by the other 5 vtec data. the 5 vtec data have to follow according the highest length of ut and seems the vtec data dimension are not same it must filled up with NaN or 0.
Comment on this Question

댓글 수: 2

Andrei Bobrov
Andrei Bobrov 2012년 4월 26일
duplicate
Walter Roberson
Walter Roberson 2012년 4월 26일
duplicate is at http://www.mathworks.com/matlabcentral/answers/36600-how-to-find-the-maximum-length-between-few-cell-arrays

댓글을 달려면 로그인하십시오.

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2012년 4월 26일

0 개 추천

Let Ut - cell array 1 x 5 , contains column vectors with size n(k) x 1, for k = 1:5.
Vtec - cell array 1 x 5, contains vector m x 1, here all m <= max(n).
e.g. data:
Ut = arrayfun(@(ii)ii*ones(randi(10),1),1:5,'un',0);
Vtec = arrayfun(@(ii)ii*ones(randi(6),1),1:5,'un',0);
% solution
n = max(cellfun('length',Ut));
out = cellfun(@(x)[x;nan(n-numel(x),1)],Vtec,'un',0);

댓글 수: 8

Vicky
Vicky 2012년 4월 26일
Im using matlab version 2008a. So i cant use randi in the coding. So is there any alternative and i also coudn't figure out the coding.
Andrei Bobrov
Andrei Bobrov 2012년 4월 26일
use 'randint'? read help for this is function
Vicky
Vicky 2012년 4월 26일
the solution you gave me filling up nans at the end.Shouldn't be in that way. Actually the vtec values have to follow the highest value of ut accordingly. so it fill up and with nans when it doesnt has the ut value anymore
Andrei Bobrov
Andrei Bobrov 2012년 4월 26일
I do not understand the problem, give a numerical example
Vicky
Vicky 2012년 4월 27일
Example 3 cell arrays,
1st cell array = [ut, vtec] with size value <4 x 2 double>
2nd cell array = [ut, vtec] with size value <2 x 2 double>
3rd cell array = [ut, vtec] with size value <5 x 2 double>
1) Find the highest/ maximum length of ut and extract the following index data ut (1st column) and save into new matrix.
2) the 2nd column and subsequent column will be filled up with vtec 1, vtec 2 and vtec3 according the 1st column(highest ut). Since the size value is not same , it has to be filled up with 0 if there is no data on that particular row.
Eg :
ut vtec1 vtec2 vtec3
1 1 2 1
1 2 0/nan 1
1 0/nan 0/nan 2
2 1 1 3
2 2 0/nan 1
Walter Roberson
Walter Roberson 2012년 4월 27일
Is that an example of the input data or the output data?
Vicky
Vicky 2012년 4월 27일
output data
Andrei Bobrov
Andrei Bobrov 2012년 4월 27일
Give the input data in numerical form as A1 = {[4 5 8 6] ', [8 6 9 1]'} and so on, and the corresponding output

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2012년 4월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by