https://www.mathworks.com/matlabcentral/newsreader/most_recent_feed
MATLAB Central Newsreader Recent Posts
Most Recent Posts
enus
©19942017 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
https://www.mathworks.com/images/membrane_icon.gif

Wed, 23 Aug 2017 04:35:09 +0000
Re: Arrange docked figures programmatically ???
https://www.mathworks.com/matlabcentral/newsreader/view_thread/112423#956000
Chaithya G R
"per isakson" <poi3@bim1.kth4.se> wrote in message <ef20384.1@webx.raydaftYaTP>...<br>
> Matlab ver 7.1 doc says:<br>
> <br>
> "You can dock figures in the MATLAB desktop ... . Once docked,<br>
> figures are placed in a figure group container, ... . You can select<br>
> from a variety of arrangements of the figures in the container."<br>
> <br>
> I have a couple of questions:<br>
> <br>
> 1. Is possible to set the position, docked/undocked, etc., for this<br>
> "figure group container" programmatically.<br>
> <br>
> 2. Is is possible to control the "variety of arrangements", e.g.<br>
> Tile, programmatically?<br>
> <br>
> I spent some time searching the documentation, without learning much.<br>
> Doc wouldn't say: cannot be done programmatically, would it? Is there<br>
> an undocumented feature?<br>
> <br>
> / per<br>
Well to answer the first question you can choose docking and undocking using this<br>
set(<figure handle>, 'WindowStyle', <'docked''normal'''modal'>)<br>
With normal is undocked...

Wed, 23 Aug 2017 03:03:14 +0000
Help to solve by using bvp4c
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349393#955999
M Kamran
I'm trying to get the two solutions of the following ODE<br>
<br>
f '''+f f ''f ' ^2=0<br>
with BCs<br>
f(0)=2, f '(0)=1+f ''(0)f '''(0) and f '(infinity)=0<br>
<br>
The code is below as <br>
<br>
<br>
function YouTubeMy<br>
<br>
solinit = bvpinit(linspace(1,10,100),[10,1]);<br>
sol = bvp4c(@rhs_bvp,@bc_bvp,solinit);<br>
x=linspace(1,3,100);<br>
Bs=deval(sol,x);<br>
plot(x,Bs(1,:));<br>
function rhs=rhs_bvp(x,y)<br>
rhs=[y(2); y(3) ; y(2)^2y(1)*y(3)];<br>
end<br>
<br>
function bc=bc_bvp(ya,yb)<br>
bc=[ya(1)2; ya(2)+1ya(3)+ya(4); yb(2)];<br>
end<br>
end<br>


Tue, 22 Aug 2017 23:20:13 +0000
Re: illustrator for matlab plots
https://www.mathworks.com/matlabcentral/newsreader/view_thread/279398#955997
jogarb
Hi,<br>
<br>
What worked for me:<br>
Copy the entire plot in Matlab into a new figure. Save it and you should be able to edit it.<br>
<br>
<br>
"Charan lANGTON" wrote in message <lsnvqq$2rt$1@newscl01ah.mathworks.com>...<br>
> "Mathew " <mathew.reeve@uni.no> wrote in message <jvbc4q$fbr$1@newscl01ah.mathworks.com>...<br>
> > Hi,<br>
> > <br>
> > You don't need to save as pdf first. I use the print function and then drag onto illustroator, embed, un group and reomve the outer frame. Then everything should be fine. Print/Save using the follwing:<br>
> > <br>
> > print('depsc','painters','loose',fname)<br>
> > <br>
> > If you are using m_map or have problems with the look of the image in illustrator then remember to rasterize once you have finished your editing and everything will look alot better. <br>
> > Hope this helps<br>
> > Mathew<br>
> ______________________________<br>
> <br>
> I am using CS6 Illustrator and cannot edit any Matlab plots. I tried your method but no success. Only very small pieces of the plot can be selected. Axes cannot be selected at all. There is often as small rectangle in the middle of the page that is marked 'page'. <br>
> Is there a way for me to edit the figures from Matlab. I tried Inkspace and am having the same difficulty. BTW, I am on Windows 7, 32 bit.<br>
> <br>
> Thank you,<br>
> <br>
> Charan

Tue, 22 Aug 2017 23:17:11 +0000
Re: Q:Simulink Scope color change
https://www.mathworks.com/matlabcentral/newsreader/view_thread/7364#955996
Chuong Le
Eric <cs_ees@hal.lamar.edu> wrote in message <3642E30E.6CC373B@hal.lamar.edu>...<br>
> I am would like to change simulink's background color of the<br>
> "Scope Block." It is currently black. Any suggestions?<br>
> <br>
> Thanks<br>
> Eric<br>
> <br>
<br>
If you use MATLAB R2015b, it's done by:<br>
+ Opening Viewer: Scope<br>
+ Click View > Style ...<br>
+ You can change the background color, line styles, etc.

Tue, 22 Aug 2017 22:04:09 +0000
Trapz calculations and patching the area between two graphs of numerical data
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349391#955995
Steven Albright
I'm new to Matlab so trying to piece together my learnings here. Thank you in advance.<br>
<br>
What I'm trying to do is plot two different lines (baseline vs actual) taken at different sample times (not a curve or line). Basically the example is measuring the area between posted speed and measured actual speed. Those data entries are entries are added as variables and I then want to use trapz to calculate the value for each line separately, but just as important I want to shade in the area between the lines using patch.<br>
<br>
One problem.. <br>
<br>
1. I can't figure out how to correctly shade in the area BETWEEN the plots using patching to represent trapazoid shaped figures. I did figure out how to do the math between the matrix of the data, and using patch show it but it's not in the right place, and doesn't handle decreasing values at all. <br>
<br>
Please help!<br>
<br>
Code so far:<br>
<br>
figure<br>
plot(mp,ts,'*', mp, ats, '*')<br>
grid on<br>
title('Speed')<br>
xlabel('Mile Marker')<br>
ylabel('Speed (mph)')<br>
ylim([0 70]);<br>
xlim([0 25]);<br>
set(gca, 'XTick', 1:25)<br>
<br>
xverts = [mp(1:end1); mp(1:end1); mp(2:end); mp(2:end)];<br>
y1verts = [zeros(1,24); ats(1:end1); ats(2:end); zeros(1,24)];<br>
y2verts = [zeros(1,24); ts(1:end1); ts(2:end); zeros(1,24)];<br>
y3verts = y2vertsy1verts<br>
p1 = patch(xverts,(y3verts),'g','LineWidth',1.5);

Tue, 22 Aug 2017 21:48:08 +0000
Warning: Explicit solution could not be found. > In dsolve (line 201)
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349390#955994
Avilés López
Hi, i'm new at matlab, i'm trying to resolve an ODE system with matlab and i'm suffering some problems. I have searched for the solutión to that problems but i wasnt able to find out were the problems.<br>
<br>
?=(??Ky)n<br>
?=?n?y<br>
<br>
?, ?,K,? y ?>0<br>
<br>
i dont know how to insert the condition "?, ?,K,? y ?>0" in the command window.<br>
<br>
When i try to resolve some ecuatión of the family:<br>
<br>
?=(??Ky)n<br>
?=?n?y<br>
<br>
like:<br>
<br>
?=n ny<br>
?=ny<br>
<br>
with the commands:<br>
<br>
>> syms n(t) y(t)<br>
>> ode1 = diff(n) == n  n*y;<br>
ode2 = diff(y) == n  y;<br>
odes = [ode1; ode2]<br>
<br>
odes(t) =<br>
<br>
diff(n(t), t) == n(t)  n(t)*y(t)<br>
diff(y(t), t) == n(t)  y(t)<br>
<br>
>> S = dsolve(odes)<br>
Warning: Explicit solution could not be found. <br>
> In dsolve (line 201) <br>
<br>
S =<br>
<br>
[ empty sym ]<br>
<br>
i dont know were my mistake is, could somebody help me? ty

Tue, 22 Aug 2017 21:03:06 +0000
Re: IPOPT as nonlinear solver
https://www.mathworks.com/matlabcentral/newsreader/view_thread/331693#955993
Rabi Kar
Thank you for sharing. I tried the same method, but my program is unable to recognize the auxdata. Below is the error,<br>
<br>
Undefined variable auxdata.<br>
<br>
Error in run_admm>jacobianstructure (line 261)<br>
M_ec = auxdata{2};<br>
<br>
Error in run_admm (line 109)<br>
[x info] = ipopt(x0,funcs{k},options{k});<br>
<br>
Error in main2_ieee (line 94)<br>
net.info_admm = run_admm(net,net.V0,exit_crit,param_vec); <br>
<br>
"Mark Mikofski" wrote in message <l1i1ha$89g$1@newscl01ah.mathworks.com>...<br>
> You have a nonlinear problem to solve but not the optimization toolbox?<br>
> <br>
> 1. First download the IPOPT mex and mfiles, and extract to your MATLAB search path.<br>
> https://projects.coinor.org/Ipopt#Download<br>
> <br>
> 2. Make an mfile that defines your objective and constraints, gradient and Jacobian.<br>
> <br>
> function [x,info] = myNonLinearProblem(x0, auxdata)<br>
> %MYNONLINEARPROBLEM Solves my nonlinear problem<br>
> % [X,INFO] = MYNONLINEARPROBLEM[X0,AUXDATA]<br>
> % returns solution, X, and INFO to my nonlinear problem<br>
> % X0 is the initial guess<br>
> % AUXDATA are any additional arguments my nonlinear problem<br>
> % requires<br>
> <br>
> x0 =x0(:); % initial guess<br>
> <br>
> %% constraints<br>
> %set all of your equations as constraints<br>
> funcs.constraints = @constraints;<br>
> % constraints require a Jacobian<br>
> funcs.jacobian = @jacobian;<br>
> % Jacobians require a sparsity structure<br>
> funcs.jacobianstructure = @jacobianstructure;<br>
> % set upper and lower bounds of constraints to zero<br>
> options.cl = zeros(size(x0)); % lower bounds<br>
> options.cu = zeros(size(x0)); % lower bounds<br>
> <br>
> %% objective<br>
> % set the objective sum of the squares<br>
> funcs.objective = @objective;<br>
> % objective requires a gradient<br>
> funcs.gradient = @gradient;<br>
> <br>
> %% options<br>
> % set QuasiNewton option<br>
> options.ipopt.hessian_approximation = 'limitedmemory';<br>
> <br>
> %% solve<br>
> [x,info] = ipopt_auxdata(x0,funcs,options);<br>
> end<br>
> <br>
> % x & auxdata must be passed as only args to<br>
> % objective, gradient, constraints and jacobian<br>
> <br>
> function f = objective(x,auxdata)<br>
> % objective is the sum of the squares of the residuals<br>
> f = residual(x,auxdata);<br>
> f = f(:);<br>
> f = f'*f;<br>
> end<br>
> <br>
> function g = gradient(x,auxdata)<br>
> f = residual(x,auxdata);<br>
> f = f(:);<br>
> g = f'*j;<br>
> end<br>
> <br>
> function f = constraints(x,auxdata)<br>
> f = residual(x,auxdata);<br>
> f = f(:);<br>
> end<br>
> <br>
> % Jacobian and Jacobian structure must be sparse<br>
> <br>
> function j = jacobian(x,auxdata)<br>
> % rows correspond to each constraint<br>
> % columns correspond to each x<br>
> [~,j] = residual(x,auxdata);<br>
> j = sparse(j);<br>
> end<br>
> <br>
> function j = jacobianstructure(x)<br>
> % x is the only arg passed to Jacobian structure<br>
> % assuming closed system of equations<br>
> % # of constraints = degrees of freedom<br>
> % therefore Jacobian matrix will be square<br>
> j = sparse(ones(size(x)));<br>
> end<br>
> <br>
> % put the equations and their derivatives here<br>
> % unfortunately IPOPT is not a Jacobianless solver :(<br>
> <br>
> function [f,j] = residuals(x,auxdata)<br>
> % calculate your residuals here<br>
> % f1(x,auxdata) = lhs1(x,auxdata)  rhs1(x,auxdata) = 0<br>
> % f2 = ...<br>
> % j1(x,auxdata) = [df1/dx1, df1/dx2, ...]<br>
> % j2 = ...<br>
> end

Tue, 22 Aug 2017 20:15:11 +0000
Re: How to xlsread a file without the empty rows being deleted
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349388#955992
Bruce Bowler
On Tue, 22 Aug 2017 18:04:08 +0000, Felix wrote:<br>
<br>
> hi,<br>
> <br>
> I am trying to read an excel file that has 31 columns. some columns have<br>
> no data but each column has a heading.<br>
> <br>
> e.g<br>
> <br>
> A1 A2 A3<br>
> 4<br>
> 5<br>
> when I read the file it automatically deletes any column that does not<br>
> fall between any two columns with values in their rows. This keeps<br>
> changing the number of columns every time I try to read the file.<br>
> <br>
> How can I read the file while maintaining the empty cells?<br>
> <br>
> I used [Weight, txt, raw]=xlsread('Results','Weight');% import Weight<br>
> file<br>
> <br>
> This is not working<br>
<br>
The cell array "raw" has the data in an "unmolested" form.

Tue, 22 Aug 2017 18:04:08 +0000
How to xlsread a file without the empty rows being deleted
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349388#955990
Felix
hi,<br>
<br>
I am trying to read an excel file that has 31 columns. some columns have no data but each column has a heading.<br>
<br>
e.g<br>
<br>
A1 A2 A3<br>
4<br>
5<br>
when I read the file it automatically deletes any column that does not fall between any two columns with values in their rows. This keeps changing the number of columns every time I try to read the file.<br>
<br>
How can I read the file while maintaining the empty cells?<br>
<br>
I used [Weight, txt, raw]=xlsread('Results','Weight');% import Weight file<br>
<br>
This is not working

Tue, 22 Aug 2017 17:52:24 +0000
Use variable from different function stack
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349389#955991
angelo
Hi all,<br>
<br>
I'm reusing old code that in some phase generates a variable that I'd like to use in my own code. The problem is that this variable (basically a SimState from a just run Simulink simulation) is not reachable from my code because is stored in another stack. I've tried to move the variable with assignin and evalin but I've failed.<br>
<br>
Is there any way to move from a ws to another (not necessarily 'base' and first 'caller') not in debug? I think this is not possible but maybe you can suggest some work around.<br>
<br>
The structure of the code is the following:<br>
<br>
% Setting the simulation to provide a snapshot of the state of the simulator at the end of the simulation<br>
set_param(model_1,'SaveFinalState','on','FinalStateName',...<br>
'xFinal','SaveCompleteFinalSimState','on','LoadInitialState', 'off')<br>
% Simulation function<br>
Simulation_fun(Parameter_set_1)<br>
..existing code containing many functions and finally a <br>
sim(model_1)<br>
<br>
Having set the simulation as above the xFinal is stored in the workspace at the end of the simulation but this is not anymore reachable by my code (because in a different stack).<br>
Here I would save the final state 'xFinal' to reinitialize another following simulation with the same simulator (model_1) with some changes on the initialization parameters (mass, position...).<br>
Something like:<br>
evalin('base', sprintf('save(''%s'',''%s'')','xFinalFile','xFinal'));<br>
<br>
Simulation_fun(Parameter_set_2)<br>
..<br>
evalin('base', sprintf('load(''%s'')','xFinalFile'));<br>
sim(model_1)<br>
<br>
This evalin does not work because the xFinal variable is not in the base ws and I cannot modify the code when the xFinal is generated.<br>
<br>
I hope you can understand and help.<br>
<br>
Thanks<br>
<br>
angelo

Tue, 22 Aug 2017 17:23:35 +0000
Re: Plotting point color as a function of a third variable
https://www.mathworks.com/matlabcentral/newsreader/view_thread/280221#955989
Prabha Chuphal
"Matt Kindig" wrote in message <hqqru5$1de$1@fred.mathworks.com>...<br>
> Use SCATTER<br>
> <br>
> scatter(x,y, size, concentration);<br>
> set(gca,'CLim',[0 1]);<br>
> <br>
> "Jonathan " <remove.this.jbent@ucsd.edu> wrote in message <hqqr5r$j1l$1@fred.mathworks.com>...<br>
> > Hi folks,<br>
> > <br>
> > I've got a dataset that I'd like to represent on a 2D colored contour plot, but the data are slightly too sparse to really warrant this. Instead, I'd like to plot my points in color, and I'd like the color to be a function of a third variable. I.e. <br>
> > <br>
> > x y concentration<br>
> > 1 1 0.12<br>
> > 2 9 0.25<br>
> > 3 7 0.93<br>
> > 4 1 0.77<br>
> > <br>
> > where concentration would be from 0 to 1, with a color bar from red to blue.<br>
> > <br>
> > Any suggestions on plot scripts already written that might save me a bit of time figuring out how to do this? Or any suggestions on how to go about doing this? The main impediment is not figuring out how to translate concentration into a color value, but figuring out how interface a set of representative color values with a Matlab plot function of some sort.<br>
> > <br>
> > (Sorry if I've missed previous threads about this, but I haven't been able to find one after a search.)<br>
> > <br>
> > Many thanks...<br>
> > Jonathan

Tue, 22 Aug 2017 16:00:34 +0000
Same characters with Tex and Latex
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349387#955988
Simon Calver
Hi,<br>
<br>
I am writing some stuff in Latex and I'd like to have the same characters in my MATLAB figures, but I can only write a nonitalic mu in Tex (i.e. for micrometers), how can I get the other characters to look the same?<br>
<br>
All the characters I want are in the following code, but not in a single label!<br>
<br>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>
figure<br>
<br>
ylabel(['{\it v}(' char(181) 'm)'],'interpreter','tex','FontName','Times New Roman')<br>
xlabel('$v$($\mu$m)','interpreter','latex') <br>
<br>
dim = [.2 .6 .3 .3]; <br>
annotation('textbox',dim,'String','I want this $v$','FitBoxToText','on', ...<br>
'edgecolor','none','interpreter','latex','fontsize',20);<br>
<br>
dim = [.6 .1 .3 .3]; <br>
annotation('textbox',dim,'String',['and this ' char(181) '!'],'FitBoxToText','on', ...<br>
'edgecolor','none','interpreter','tex','fontsize',20,'FontName','Times New Roman');<br>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>
<br>
Thanks.

Tue, 22 Aug 2017 15:59:08 +0000
Re: GUIDE panel resize
https://www.mathworks.com/matlabcentral/newsreader/view_thread/299081#955987
Adam Danz
"Fraser Dickson" wrote in message <ied9a6$jkg$1@fred.mathworks.com>...<br>
> Hi there is something thathas been bothering me for a while now.<br>
> <br>
> Is there a way when using GUIDE to stop the contents of a panel being resized when you resize the panel itself? I want to fit more items in the panel so i make it larger but the contents themselevs just get larger to fill the empty space. I therefore need to take the contents out of the panel , resize the panel on its own and then put the content back in, Its really annoying.<br>
> <br>
> Any Help Much Appreciated<br>
<br>
Another solution I stumbled upon is to select the main figure component when using GUIDE, then go to Tools > GUI Options... and under 'Resize behavior', select Nonresizable. Now you can resize the panel without its components changing size. Note that your figure will also be nonresizable by the user. One way to get around that is to make your figure nonresizable within GUIDE, make the changes you want to the panel, and then make the figure 'Proportional' again. <br>
<br>
Adam

Tue, 22 Aug 2017 15:14:07 +0000
Re: imagesc NaN values
https://www.mathworks.com/matlabcentral/newsreader/view_thread/278416#955986
Simone Sabbatini
"Elly Wang" wrote in message <msa6db$51k$1@newscl01ah.mathworks.com>...<br>
> "Oliver Woodford" wrote in message <i4e7mk$qjc$1@fred.mathworks.com>...<br>
> > "Camille Couzi" wrote:<br>
> > I have a matrix with NaN values and I am displaying them on an imagesc.<br>
> > <br>
> > % Data:<br>
> > data = peaks(256);<br>
> > data(rand(size(data))<0.01) = NaN;<br>
> > <br>
> > % Command:<br>
> > sc(data, 'jet', [0.5 0.5 0.5]);<br>
> > <br>
> > You can download sc here:<br>
> > <a href="http://www.mathworks.com/matlabcentral/fileexchange/16233scpowerfulimagerendering">http://www.mathworks.com/matlabcentral/fileexchange/16233scpowerfulimagerendering</a><br>
> > <br>
> > HTH,<br>
> > Oliver<br>
> <br>
> Thank you so much for providing this. This is exactly what I need.<br>
<br>
Hi Oliver,<br>
I report this behaviour of your function sc:<br>
I am in a similar situation of that of the posts above, then I used the sc function as to represent in grey the NaN values of a matrix data (n X 3). I got some troubles as adding the yticklabels did not work:<br>
set(gca,'yticklabel',labels)<br>
I then followed the suggestion of using image(sc(data,'jet',[0.5 0.5 0.5])) reported in a previous post, and it worked but the colorbar scale was messed up. Then I tried imagesc(sc(data)) and everything worked fine... <br>
<br>
Thanks for your help<br>
<br>
Simone

Tue, 22 Aug 2017 14:51:08 +0000
Re: imagesc NaN values
https://www.mathworks.com/matlabcentral/newsreader/view_thread/278416#955985
Simone Sabbatini
"Elly Wang" wrote in message <msa6db$51k$1@newscl01ah.mathworks.com>...<br>
> "Oliver Woodford" wrote in message <i4e7mk$qjc$1@fred.mathworks.com>...<br>
> > "Camille Couzi" wrote:<br>
> > I have a matrix with NaN values and I am displaying them on an imagesc.<br>
> > <br>
> > % Data:<br>
> > data = peaks(256);<br>
> > data(rand(size(data))<0.01) = NaN;<br>
> > <br>
> > % Command:<br>
> > sc(data, 'jet', [0.5 0.5 0.5]);<br>
> > <br>
> > You can download sc here:<br>
> > <a href="http://www.mathworks.com/matlabcentral/fileexchange/16233scpowerfulimagerendering">http://www.mathworks.com/matlabcentral/fileexchange/16233scpowerfulimagerendering</a><br>
> > <br>
> > HTH,<br>
> > Oliver<br>
> <br>
> Thank you so much for providing this. This is exactly what I need.