what is wrong with this code f = @(k,c){exp(-1.*(12.5./c)^k)-exp(-1.*(26.83./c)^k)+(1./(12.5)^3-(6.26^3)).*integral(@(v)((v^3-6.26^3).*(k./c).*((v./c)^k-1)*exp(-1.*(v./c)^k)),6.26,12.5)}; in matlab

There are a few issues with the code you provided.

First, the function handle declaration should use the anonymous function syntax @(k,c). So, the correct declaration should be:

main.m
f = @(k,c) exp(-1.*(12.5./c).^k) - exp(-1.*(26.83./c).^k) + (1./(12.5)^3 - (6.26^3)) .* integral(@(v) (v^3 - 6.26^3) .* (k./c) .* ((v./c).^k - 1) .* exp(-1.*(v./c).^k), 6.26, 12.5);
182 chars
2 lines

Second, the power operator in MATLAB is ^, not **. Therefore, in the code snippet, you should use ^ instead of **.

Additionally, you might encounter a problem with the division operator / in MATLAB. If k and c are arrays, you need to use the element-wise division operator ./ instead. However, if k and c are scalars, the division operator / is correct.

Other than these syntax issues, the logic and correctness of the code can only be determined based on the specific problem you are trying to solve.

related categories

gistlibby LogSnag