ans = 
How can I solve the problem in integral code?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Share a link to this question
Solve the problem
Accepted Answer
1 vote
Loop over the values of the sigma-vector - thus call "vpaintegral" for each sigma value separately.
Or alternatively make your code a function and call it from a script with a single sigma-value as input.
Further, I'd recommend first to use "integral" instead of "vpaintegral" to save computation time.
And where do you compute w1 - w6 - the variables you try to plot at the end of your code ?
Works because "vpaintegral" is called for each sigma-value separately:
syms r
f = r^2;
sigma = 0:0.1:1;
arrayfun(@(sigma)vpaintegral(f,r,0,sigma),sigma)
Does not work because "vpaintegral" is called once with the complete sigma-vector:
syms r
f = r^2;
sigma = 0:0.1:1;
vpaintegral(f,r,0,sigma)
Operands to the logical AND (&&) and OR (||) operators must be convertible to logical scalar values. Use the ANY or ALL functions to reduce operands to logical scalar values.
Error in sym/vpaintegral (line 182)
(isinf(b) && isempty(symvar(b)) && ~isreal(b))
8 Comments
Shreen El-Sapa
on 12 May 2025
Torsten
on 12 May 2025
It's the same problem as above. "vpaintegral" can integrate one function over one interval of integration at a time. Thus alpha must be a single value when you call "vpaintegral", not a vector of values.
Shreen El-Sapa
on 12 May 2025
Thanks I will try to use it.
Shreen El-Sapa
on 12 May 2025
Excuse me, Can I do this for 6 integrals?
Shreen El-Sapa
on 12 May 2025
Moved: Torsten
on 12 May 2025
please see this:
Torsten
on 12 May 2025
Try the attached revised code.
Walter Roberson
on 12 May 2025
Note that vpaintegral() can handle the case where the part to be integrated is non-scalar, but cannot handle the case where the limits to integration are non-scalar.
syms x
vpaintegral([sin(x), cos(x)], x, [0 1])
ans = 
Thank you for the info.
So the changes to your last code (test_microstrength.m) were not necessary (except for the final plotting).
More Answers (0)
Categories
Find more on Calculus in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)