I need to save result of three loops in same file data if you possible for plot graphs or curves in 3D ?

1 次查看(过去 30 天)
Hi freinds ,
I have some with Matlab I want to save a result in same file data or data file but I have three loops with (for )
can you help me for do that ?
thanks.
this is my example :
for mass_ratio =0.01:0.01:0.1 it means this vector has (10 element)
for frequency_tuning=0.85:0.1:1.15 it means this vector has (4 element)
for damping_ratio=0.01:0.01:0.2 it means this vector has (20 element)
%result %
displacement
acceleration
end
end
end

回答(1 个)

darova
darova 2020-2-15
example
mass_ratio = 0.01:0.01:0.1;
frequency_tuning = 0.85:0.1:1.15;
damping_ratio = 0.01:0.01:0.2;
displacement = zeros( length(mass_ratio),length(frequency_tuning), length(damping_ratio) );
acceleration = zeros( length(mass_ratio),length(frequency_tuning), length(damping_ratio) );
for i = 1:length(mass_ratio) %it means this vector has (10 element)
for j = 1:length(frequency_tuning) %it means this vector has (4 element)
for k = 1:length(damping_ratio) %it means this vector has (20 element)
%result %
displacement(i,j,k) = ...
acceleration(i,j,k) = ...
end
end
end
save data displacement acceleration

类别

Help CenterFile Exchange 中查找有关 Chemistry 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by