I do not know how to create this complicated SUM equation within MATLAB for multiple variables?

조회 수: 1 (최근 30일)
I have to store a data table in MATLAB, and then run them through a complicated equation, which can both be seen in the attached files as examples. However, I do not know how to store those values, or write that equation, or call those values and run the equation. I really could use some help here...
  댓글 수: 4
Zachary
Zachary 2024년 10월 12일
편집: dpb 2024년 10월 12일
It's just how the value is "defined", I guess. Here is what I was thinking so far:
SmallSum1 = (B1*lambda)./((w1+lambda).^2);
BigSum1 = (euler(w1,t))./SmallSum1;
SmallSum6 = (B6*lambda)./((w6+lambda).^2);
BigSum6 = (euler(w6,t))./SmallSum6;
plot(BigSum1);
plot(BigSum6);
I separated the equation into the smaller sum (in the denominator) and the overall sum, then calling the smaller sum into the larger one. However, that just generates a whole slew of errors.
dpb
dpb 2024년 10월 12일
편집: dpb 2024년 10월 12일
Well, it isn't consistent with the formula which says the outer sum goes through B+1 so if B==6, B+1-->7. Unless B is supposed to have been 5, instead? Who knows, all we can see is what is posted; no idea from whence this all came, but I'd guess the table's simply wrong...now whether it was intended to have B==6 and they didn't add the extra row, or they have as many terms as they wanted and just entered the wrong number for B is indeterminate.
As for the code; you've coded up the individual terms, but not the sums...
I was having trouble reading/deciphering the equation, I didn't recognize the e was/is the Euler function; I thought it was the exponential and then sub- and superscripts were most confusing...

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

답변 (1개)

Dr W Kurt
Dr W Kurt 2024년 10월 14일
B = [B1, B6]; % Array for B values
w = [w1, w6]; % Array for w values
lambda = ...; % Define lambda (if not already defined)
t = ...; % Define t (if not already defined)
% Preallocate arrays for results
SmallSum = zeros(1, 2);
BigSum = zeros(1, 2);
% Loop through both sets of B and w
for i = 1:2
SmallSum(i) = (B(i) * lambda) ./ ((w(i) + lambda).^2);
BigSum(i) = euler(w(i), t) ./ SmallSum(i);
end
% Plot both results
plot(BigSum(1)); % Plot for BigSum1
hold on;
plot(BigSum(2)); % Plot for BigSum6
hold off;

카테고리

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

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by