필터 지우기
필터 지우기

Why am I receiving an error message in an array calculation?

조회 수: 2 (최근 30일)
Benjamin Horsley
Benjamin Horsley 2021년 2월 18일
댓글: Benjamin Horsley 2021년 2월 18일
I'm having some difficulty performing an array calculation. I would like to fill the contents of column 3 based on a specific formula using the contents of columns 1 and 2. I have some example code below.
% Example data.
column1data = [231.3 228.8 237.5 222.5]';
column2data = [107.5 121.3 108.8 111.3]';
% I want to create an addtional 3 columns so I end up with a 4 x 5 array.
% I first create a vector that is the same length as vectors 1 and 2.
lendata = length(column1data);
% I then create three additional vectors (columns) of zeros and join all together.
column3 = zeros(1, lendata)';
column4 = zeros(1, lendata)';
column5 = zeros(1, lendata)';
array = [column1data column2data column3 column4 column5];
Once I've created the array, I want to use the below formula to return 4 values in column 3.
array(:, 3) = (81*9.81)*(3.14/2)*((array(:, 2)/array(:, 1)) + 1);
However, I get an error message returned. Can someone please advise what I'm missing?
Thank you.

채택된 답변

Walter Roberson
Walter Roberson 2021년 2월 18일
use ./ not /

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by