필터 지우기
필터 지우기

make mx1 size array with m number of inputs

조회 수: 3 (최근 30일)
Madhav
Madhav 2022년 9월 9일
댓글: Rik 2022년 9월 9일
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

답변 (1개)

Chunru
Chunru 2022년 9월 9일
%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
Madhav
Madhav 2022년 9월 9일
FIrst , I want to input size of array, for example 5 and i want to give values. FOr for exampke 0, 0.2, 0.3, 0.4, 0.5 like this.
Rik
Rik 2022년 9월 9일
Did you try this code? Did you notice how it might be possible to use these functions for what you describe?

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

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by