Make scalar data into a vector
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
for i=1:length(x)
a(i)=round(-19.93984628*x(i).^2-19.26822854*x(i)+28.63259561);
%Use inverse matrix to form system curve equation
totalX1=sum(X1);
totalY1=sum(Y1);
totalA=sum(X1.*Y1);
totalB=sum(X1.^2);
totalC=sum(X1.^3);
totalD=sum(X1.^4);
totalE=sum(X1.^2.*Y1);
n=length(X1);
A1=[n totalX1 totalB;totalX1 totalB totalC;totalB totalC totalD];
B1=[totalY1;totalA;totalE];
S1=A1\B1;
b(i)=round(S1(3)*x(i).^2+S1(2)*x(i)+S1(1));
if a(i)==b(i)
fprintf(fid,'\n\nFor Single Pump\n');
fprintf(fid,'------------------\n');
fprintf(fid,'The Operating point is at Q=%.3fm3/s\n\n',x(i));
RQ=0.7; %Requested flow rate
end
end
the above is my coding. What I would like to ask for help is: how can I make the 'x' values (scalar) when 'if a(i)==b(i) into a vector? there were multiple output for x values but i want to compile them into a vector.
Hope can help.
0 commentaires
Réponses (1)
KSSV
le 26 Jan 2022
a(i)==b(i) gives a logical output i.e. either 0 or 1. If a and b are vectors a == b, gives a logical vector as output having 1 and satisfied location and 0 at condition not satisfied. To check you can use
any(a==b)
2 commentaires
Voir également
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!