make mx1 size array with m number of inputs
4 views (last 30 days)
Show older comments
clc
clear
close all
zai=[ 0.0 0.4 0.2 0.3 0.4]; %I want to change the size of this array based on inputting the size value and I will give the n number of values.
beta=0:0.005:4;
for i=1:length(zai)
for j=1:length(beta)
d(i,j)=(1/((1-beta(j)^2)^2+(2*beta(j)*zai(i))^2))^0.5;
end
0 Comments
Answers (1)
Chunru
on 9 Sep 2022
%zai=[ 0.0 0.4 0.2 0.3 0.4]; %I want to change the size of this array based on inputting the size value and I will give the n number of values.
str = input("Enter N numbers: ", "s");
zai = sscanf(str, '%f');
beta=0:0.005:4;
for i=1:length(zai)
for j=1:length(beta)
d(i,j)=(1/((1-beta(j)^2)^2+(2*beta(j)*zai(i))^2))^0.5;
end
2 Comments
Rik
on 9 Sep 2022
Did you try this code? Did you notice how it might be possible to use these functions for what you describe?
See Also
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!