Find the max using PSO

7 views (last 30 days)
kyungdoo lee
kyungdoo lee on 26 Oct 2021
Commented: Star Strider on 26 Oct 2021
T = readtable('data1.xlsx') ;
T = table2array(T) ;
x = T(1,2:end); % coil length
y = T(2:end,1); % magnitude length
Z = T(2:end,2:end); % use fillmissing to fill NaNs
[X,Y] = meshgrid(x,y) ;
[xq,yq] = meshgrid(2:0.1:10); % grid interval 0.1
Zq = interp2(x,y,Z,xq,yq,'spline');
figure
AA = surf(xq,yq,Zq);
title('(spline,cubic,makima) Interpolation Using Finer Grid');
%%
% example
% if input (1, 1), in interpolation (2.0, 2.0)
% if input (23, 23) , in interpolation (42, 42)
% if input (81, 81) , in interpolation (10.0 , 10.0)
% Upper limit& Lower limit are 1~81
Zq(1,1)
Zq(23,23)
Zq(81,81)
I have interpolated the attached table with the above code. Now I want to find the max using PSO, but I don't know how.

Accepted Answer

Star Strider
Star Strider on 26 Oct 2021
This is at least the second time (the first that I°m aware of is how to get maximum value of this code) you’ve asked the same question and still haven’t supplied the necessary information!
And still more continue to appear!
  9 Comments
kyungdoo lee
kyungdoo lee on 26 Oct 2021
In the graph above, the Z-axis number is too small to display well. How can I get a more accurate z-value?
Star Strider
Star Strider on 26 Oct 2021
As always, my pleasure!
The ‘Z’ value is as accurate as it needs to be. To increase the numbers displayed in the text object, increase the precision in the format specifying it —
text(xq(c),yq(r),Zq(r,c), sprintf('\\leftarrow (%.2f, %.2f, %.8f)',xq(c),yq(r),Zq(r,c)), 'Horiz','left', 'Vert','middle', 'FontSize',10, 'Color','r', 'Rotation',90)
To display it in its full precision, either use —
format long
or —
fprintf('Zq_max = %23.15E\n',Zq(r,c))
to print it in full precision. (The format functions apparently do not work with the online Run feature here, however they will work on your computer.)
.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!