How can I resolve Error Using max function

3 views (last 30 days)
Sumit Saha on 8 Jan 2021
Commented: Star Strider on 9 Jan 2021
clc
clear all;
close all;
for kk =1:44
for k=1:50
% here drift values are in the form of drift ratio
Roof_Drift_max(kk,k,:)= max(abs(Roof(:,2)));
Story1_Drift_max(kk,k,:)= max(abs(Story1(:,2)));
Story2_Drift_max(kk,k,:)= max(abs(Story2(:,2)));
Story3_Drift_max(kk,k,:)= max(abs(Story3(:,2)));
Story4_Drift_max(kk,k,:)= max(abs(Story4(:,2)));
Story5_Drift_max(kk,k,:)= max(abs(Story5(:,2)));
Story6_Drift_max(kk,k,:)= max(abs(Story6(:,2)));
Story7_Drift_max(kk,k,:)= max(abs(Story7(:,2)));
Story8_Drift_max(kk,k,:)= max(abs(Story8(:,2)));
Story9_Drift_max(kk,k,:)= max(abs(Story9(:,2)));
% Maximum Interstorey Drift Ratio
MIDR(kk,k,:) =max(Roof_Drift_max(kk,k,:),Story1_Drift_max(kk,k,:),Story2_Drift_max(kk,k,:),Story3_Drift_max(kk,k,:),Story4_Drift_max(kk,k,:),...
Story5_Drift_max(kk,k,:),Story6_Drift_max(kk,k,:),Story7_Drift_max(kk,k,:),Story8_Drift_max(kk,k,:),Story9_Drift_max(kk,k,:));
end
end

Star Strider on 8 Jan 2021
I am not certain what you want.
One option is to enclose all the arguments within square brackets [], effectively concatenating them:
MIDR(kk,k,:) =max([Roof_Drift_max(kk,k,:),Story1_Drift_max(kk,k,:),Story2_Drift_max(kk,k,:),Story3_Drift_max(kk,k,:),Story4_Drift_max(kk,k,:),...
Story5_Drift_max(kk,k,:),Story6_Drift_max(kk,k,:),Story7_Drift_max(kk,k,:),Story8_Drift_max(kk,k,:),Story9_Drift_max(kk,k,:)]);
This will produce an ‘MIDR’ matrix with the same dimensions as the argument matrices.
Experiment with other approaches to get different results.
Sumit Saha on 9 Jan 2021
I've attached a zip file for your reference
Star Strider on 9 Jan 2021
Try this to extract the variables:
uz = unzip('IDAOutput.zip');
k2 = 0;
for k1 = 1:numel(uz)
if ~isdir(uz(k1))
[~,txtname] = fileparts(uz{k1});
k2 = k2+1;
LD{k2,1} = txtname;
end
end
I have to unzip it, so I included tahat as part of my code. Change my code to work with the .zip file or it was created from. My code extracts the contents of the .zip file to a series of cell arrays, with the first element of the cell array being the name of the file it came from, and the second cell array the contents of that file as a double matrix.
So to get the information for the first 5 elements of ‘LD(1)’:
BldgPart_1 = [LD{1,1}]
BldgPrtData_1 = [LD{1,2}(1:5,:)]
produces:
BldgPart_1 =
'Roof'
BldgPrtData_1 =
0.002 6.9378e-08
0.004 6.9378e-08
0.006 6.9378e-08
0.008 6.9378e-08
0.01 6.9378e-08
and for ‘LD(40)’:
BldgPart_40 = [LD{40,1}]
BldgPrtData_40 = [LD{40,2}(1:5,:)]
produces:
BldgPart_40 =
'Story9'
BldgPrtData_40 =
0.002 5.5276e-07
0.004 5.5276e-07
0.006 5.5276e-07
0.008 5.5276e-07
0.01 5.5276e-07
I leave the rest to you.

Feng Shui Déco on 9 Jan 2021
Yeah, you have to close your arguments with square bracket.

Categories

Find more on Structures in Help Center and File Exchange

R2017a

Community Treasure Hunt

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

Start Hunting!