![]() |
The variable is not being assigned a value for some reason. (MATLAB)
<p>For some reason, result_spmd is not being assigned a value and I am not sure what I have done wrong. Can someone please help me?</p>
<pre><code>spmd(4) interval_size = (finish-start) / No_intervals; range = finish - start; start_spmd = ((labindex - 1) * (range/4)) + start; finish_spmd = start_spmd + (range/4); fprintf ("Worker %d will count from %f to %f ", labindex, start_spmd, finish_spmd ); for x = start_spmd:interval_size:(finish_spmd - interval_size) result_spmd = result_spmd + 0.5 * ( Function_to_Integrate(x) + Function_to_Integrate(x+interval_size) ) * interval_size; %Issue is on this line end end fprintf ("The value from worker 1 is %f\n", result_spmd{1} ); fprintf ("The value from worker 2 is %f\n", result_spmd{2} ); fprintf ("The value from worker 3 is %f\n", result_spmd{3} ); fprintf ("The value from worker 4 is %f\n", result_spmd{4} ); result_total = ( result_spmd{1} + result_spmd{2} + result_spmd{3} + result_spmd{4} ); % Display the answer fprintf("The integral of x^2 is %f arbituary units\n\n",result_total); toc % This is the funtion you will be integrating (y=x^2) function y = Function_to_Integrate(x) y = x*x; end </code></pre> [url=https://stackoverflow.com/questions/59038444/the-variable-is-not-being-assigned-a-value-for-some-reason-matlab]More answer...[/url] |
所有时间均为北京时间。现在的时间是 19:41。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.