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

4 views (last 30 days)
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 Comments
Zachary
Zachary on 12 Oct 2024
Edited: dpb on 12 Oct 2024
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 on 12 Oct 2024
Edited: dpb on 12 Oct 2024
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...

Sign in to comment.

Answers (1)

Dr W Kurt
Dr W Kurt on 14 Oct 2024
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;

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!