필터 지우기
필터 지우기

How can write this equation in matlab?

조회 수: 1 (최근 30일)
S AsZ
S AsZ 2023년 9월 15일
답변: Nathan Hardenberg 2023년 9월 15일

Hi everyone. Can you guide me to write the code of this equation? In this equation Rcl is a variable, qqdc is a binary variable, and rdc and Rdk are parameters with specified values.

채택된 답변

Nathan Hardenberg
Nathan Hardenberg 2023년 9월 15일
You do not specify what l is so I will disregard it at first. Also your variables are vectors/matricies if I see that correctly. I assume K is the index of the last element in the vector. Thats why I'm writing qqdc(2:end) for example. Be sure to also check the prod()-function to know what it is doing.
% variables / vectors
qqdc = [1; 1; 1];
rdc = [2.1; 2.2; 2.3];
Rdk = [3.1; 3.2; 3.3];
% equation
Rcl = (qqdc(1)*rdc(1)*Rdk(1)) + ...
((1 - qqdc(1)*rdc(1)*Rdk(1)) * ...
(1 - prod(1 - qqdc(2:end).*rdc(2:end).*Rdk(2:end)))) % using the .* operator to do elementwise product
Rcl = 220.3178
Now you could throw this in a for loop and calculate for every l value. Not that great of a way. So here I'm trying to do it with vector operations. Be aware that this is harder to wrap your head around (in my opinion) and because I don't have examples to test with I can't really check if it is correct the way you want it to be.
% variables / vectors / matrecies
qqdc = [1 1; 1 1; 1 1] % with k rows and l colums
qqdc = 3×2
1 1 1 1 1 1
rdc = [2.1 2.5; 2.2 2.6; 2.3 2.7] % with k rows and l colums
rdc = 3×2
2.1000 2.5000 2.2000 2.6000 2.3000 2.7000
Rdk = [3.1; 3.2; 3.3] % with k rows
Rdk = 3×1
3.1000 3.2000 3.3000
Rcl = (qqdc(1,:).*rdc(1,:).*Rdk(1)) + ... % I am assuming an elementwiese product here
((1 - qqdc(1,:).*rdc(1,:).*Rdk(1)) .* ...
(1 - prod(1 - qqdc(2:end,:).*rdc(2:end,:).*Rdk(2:end,:))))
Rcl = 1×2
220.3178 391.8331

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by