# Aerobalence Code , how do i get the code to output just 1 answer

조회 수: 1(최근 30일)
Domhnall Morris 2021년 4월 1일
답변: Asvin Kumar 2021년 5월 20일
clear
clc
front=0; % initialise front variable
rear=0;
m=size(AeroBalence); % find the size of the matrix AeroBalence
RH_F=AeroBalence(2:m(1),1); % Front ride height matrix
RH_R = AeroBalence(1,2:m(2)); % REAR ride height matrix
AB=AeroBalence(2:m(1),2:m(2)); % AeroBalence %
while front<RH_F(1,1) || front>RH_F(7,1)
prompt = strcat('insert a front ride height larger than', num2str(RH_F(1,1)));
front = input(prompt);
end
while rear<RH_R(1,1) || rear>RH_R(1,7)
prompt1 = strcat('insert a rear ride height larger than', num2str(RH_R(1,1)));
rear = input(prompt1);
end
for i=1:size(RH_F)-1
min_front=RH_F(i,1);
max_front=RH_F(i+1,1);
if front>= min_front && front < max_front
for j=1:7
newAeroBalence(j)= AB(i,j)+(AB(i+1,j)-AB(i,j))*((front-min_front)/(max_front-min_front))
end
elseif front==max_front
newAeroBalence(:)=AB(i+1,:)
end
end
this is the code im using , matlab is not my strong point and im wondering how you can get the code to output just 1 answer instead of 7. how do i get the code to pick a rear ride height to give out 1 conclusive answer thanks
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
Domhnall Morris 2021년 4월 2일
im looking to have a single value for the aerobalence to be output

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

### 답변(1개)

Asvin Kumar 2021년 5월 20일
The 7 outputs are because you have an assignment statement inside a for loop that runs 7 times. You are not suppressing the output. Use a semicolon at the end to suppress output. For example:
a=7 % prints output
a = 7
a=7; % doesn't print output
As to what you want printed out, I'm not sure because I don't have context for the algorithm in the code.

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

### Community Treasure Hunt

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

Start Hunting!

Translated by