https://kr.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions20190820T22:37:42Ztag:kr.mathworks.com,2005:Question/47693720190820T22:37:42Z20190820T22:37:42Zleast square curve fit Hi All,
I am trying to fit my data into a exponential equation. My code is as follows :
However it is not fitting to the graph at all. I am getting a fitted and original figure as attached. May I know what causing this problem. It is not showing any error as well %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Filters relaxation data clear all %read data and split into variables
clc
clear all
file1='creep10.charmm';
fileid1=fopen(file1);
vis=textscan(fileid1,'%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f',2001,'HeaderLines',67,'Collectoutput',true);
vis=cell2mat(vis);
sigma0=(10*69.478/1196.7)*10^8;
%%%% least square curve fit
xdata=vis(:,2)*10^3;
ydata=(vis(1,24)vis(:,24))/(173.5);
time=xdata;
stress=sigma0;
strain=ydata;
D=strain;
[s1,s2]=size(D);
ii=1:s1;
time_temp=time(ii);
time_hold=time_temptime_temp(1);
%Curvefit input parameters
d0=[1 1 1 1 1 1 1 1 1 1 1];
fun = @(d,time_hold)d(1)+d(2)*(1exp(time_hold/d(3)))+d(4)*(1exp(time_hold/d(5)))+d(6)*(1exp(time_hold/d(7)))+d(8)*(1exp(time_hold/d(9)))...
+d(10)*(1exp(time_hold/d(11)));
d = lsqcurvefit(fun,d0,time_hold,D);
%Use builtin lsqcurvefit function
fp=d;
fp_1 = @(d) fp(1)+fp(2)*(1exp(time_hold/fp(3)))+fp(4)*(1exp(time_hold/fp(5)))+fp(6)*(1exp(time_hold/fp(7)))+fp(8)*(1exp(time_hold/fp(9)))...
+fp(10)*(1exp(time_hold/fp(11)));
figure (1)
plot (vis(:,2)/1000,D/sigma0)
hold on
plot (time_hold, fp_1(time_hold)/sigma0)
title('\bf Creep test','fontsize',20 )
xlabel('\bf Time (ps)','fontsize',20 )
ylabel('\bf Compliance (m^2/N) ','fontsize',20 )
lg=legend ('MD','11 parameter Model');
lg.FontSize=20;
lg.Location='southeast';
saveas(gcf,'fitted.png')
Thank you!khandakar abu hasan al Mahmudhttps://kr.mathworks.com/matlabcentral/profile/authors/9674858khandakarabuhasanalmahmudtag:kr.mathworks.com,2005:Question/47693620190820T22:36:42Z20190820T22:36:42ZX axis is not displaying final valueI am trying to plot my xaxis from min(x) to max(x) but for some reason the final value wont display, even though the plot runs to the final value.
The values run from 0115 and I am looking to display 115 on the xaxis, how can I do this?
Thanks!
figure;
colormap(jet); %changes colour scheme
caxis([80 45]); % sets scale on colour bar
axis tight;
view(0,90); %flip plot so it becomes 2D
ylim ([0 20000]);
set(gca,'tickdir','out','fontname',... %change size of axes
'arial','fontsize',14);
xlim([0, t(end)]); %change range of x axis
xticks(0:15:115); %x axis labels in intervals of 15
Louise Wilsonhttps://kr.mathworks.com/matlabcentral/profile/authors/15959472louisewilsontag:kr.mathworks.com,2005:Question/47693520190820T22:36:23Z20190820T22:36:23ZI bought R2019a and it will not let me open it, every time it comes up with an error. I'm a student and I bought R2019a and it will not let me open it, every time it comes up with an error. Caroline Turnerhttps://kr.mathworks.com/matlabcentral/profile/authors/14505828carolineturnertag:kr.mathworks.com,2005:Question/47672020190819T16:00:36Z20190820T22:36:15ZDeleting circles drawn using viscircles Hello, I am trying to delete a group of circles drawn on my plot using viscircles. I have saved the group to a handle, but when I try to execute the delete(handle) command the circles still remain. I am using 'hold on' to continuously update the same figure could that be interfering? The points that the circles surround are removed when I delete their handle. below is a picture of before and after I run the delete(handle) commands. Would usign data linking/sourcing be a better option?? Would showing the updates via a new subplot window also work ??
Before:
After:
Vance Blakehttps://kr.mathworks.com/matlabcentral/profile/authors/15947118vanceblaketag:kr.mathworks.com,2005:Question/47690820190820T18:09:29Z20190820T22:34:05ZAvoid turning plot when on a figure Hello!
I need to plot x and y coordinates over a figure representing a map, which will be displayed at a viewport on the rightop of the figure.
However, when I use the code below, it works, but y coordinates of the points are flipped. Using only the first three lines of the code places the figure properly; using the code without the image function places the points in the correct position. When I run the whole code, yaxis flips and ycoordinates are plotted flipped. I tried set(gca,'Ydir','reverse'), but it did not work.
Any help?
Thanks.
ha2=axes('position',[0.75, 0.55, .22,.42,]); % position of the viewport
image(mapabase,'XData',[49.7 48.7],'YData',[1.12 1.67]) %image workin as a map
hold on
for k=1:1:qtde_psgns
plot(navios_cel{k}(:,4),navios_cel{k}(:,3),'.','markers',5); %coordinates of several surveys
end
grid on
hold off
xlim ([49.7 48.7])
ylim ([1.12 1.67])Diego Fonsecahttps://kr.mathworks.com/matlabcentral/profile/authors/15651016diegofonsecatag:kr.mathworks.com,2005:Question/47693420190820T22:31:34Z20190820T22:31:34ZHow do I deactivate MATLAB?How do I deactivate MATLAB 2019Rosana Seggiarohttps://kr.mathworks.com/matlabcentral/profile/authors/6411861rosanaseggiarotag:kr.mathworks.com,2005:Question/47693220190820T21:55:08Z20190820T22:29:24ZWhy can't 32bit values be converted to 24bit values? I have an array with 5 columns of data points and I need to convert the points from 32bit to 24bit. The cast or typecast functions don't support 'bit24' as the precision value.
Is there another way to do this? I also tried writing the values into a new binary file and writing them back out at 24bit, but it writes them out as a double. Hannah Petersonhttps://kr.mathworks.com/matlabcentral/profile/authors/13623699hannahpetersontag:kr.mathworks.com,2005:Question/47692920190820T21:29:54Z20190820T22:27:38ZHow to trim segments to fit a squareintermed=[X1 X2 Y1 Y2 m b]% where (X1,Y1) represents the lower left endpoint, (X2, Y2) represents the upper right endpoint, m and b are the slope and intercept
Tau = zeros(size(intermed));
for i=1:length(intermed)
if intermed(i,3)<0.00% Removes any Y1 less than 0
Tau(i,3)=0.00% Replace any Y1<0 by 0
Tau(i,1)=(0.00001intermed(i,6))/(intermed(i,5));% Computes the new X1 using intercept and slope
else if intermed(i,4)>40.00% Removes any Y2 less than 0
Tau(i,4)=40% Replace any Y2>40 by 40
Tau(i,2)=(40intermed(i,6))/(intermed(i,5));
else
Tau(i,1)=intermed(i,1);
Tau(i,2)=intermed(i,2);
Tau(i,3)=intermed(i,3);
Tau(i,4)=intermed(i,4);
Tau(i,5)=intermed(i,5);
Tau(i,6)=intermed(i,6);
end
end
end
I have 100 segments with the endpoints coordinates. I want to trim these segments to fit into a square of 40 by 40. X coordinates are already in the range 040. But for the Y coordinate i have some outliers (<0 and >40). The code above is my attempt to trim these outliers, but it doesn't work. Thanks in advance.Romeo Akarahttps://kr.mathworks.com/matlabcentral/profile/authors/15191153romeoakaratag:kr.mathworks.com,2005:Question/47693320190820T22:26:43Z20190820T22:26:43ZHow would I create a script to read files linebyline to save memoryHey guys,
I've done the MatLab Onramp, but I still feel extremely confused about what the hell I'm doing and it's frustrating me. I don't even know how to google the right qeustions, and interpreting pages from this website is a task that alone is like learning another language. Learning German was easier than this it feels like. So I'm sorry if I'm asking stupid questions, but I feel like I've been thrown into the deep end.
I have a .txt file that is 1,000,000,000 lines long, give or take a few 100,000,000 (no two files are the same length)
It constists of only numbers, no headers that I'm aware of.
Because of the file size, I cannot load the whole file. It needs to be read in portions. I'd rather not split the file or
I'm looking to gather variance data every 100,000 data points, to be organized in a single column/multiple row format.
Idealy, I'd also like to have new columns generated every 360 variance data points, however this isn't as important as generating the varience data first.
Thanks for the help!Eric Lundinhttps://kr.mathworks.com/matlabcentral/profile/authors/15888319ericlundintag:kr.mathworks.com,2005:Question/47692820190820T21:29:33Z20190820T22:09:05ZHI, I have a question regarding histogram plots in matlabI have a column vector max_ratio that contains values ranging from 0 upto 60. There are roughly 70,000 values inside this vector and almost 69,500 of these values fall within 0 and 10. As a result when I try to plot the histogram the values above 10 don't properly show.
Is there a way to lump the values above 10 together and show it at 10? the values before 10 will show up normally but all the values above 10 will lump together without going further than 10 along xaxis.
I am attaching the code and result I get from it below.
myhist1 = histogram(max_ratio_o,100);
hold on;
BinCenters = (myhist1.BinEdges(2:end)+myhist1.BinEdges(1:end1))/2;
plot(BinCenters,myhist1.Values,'rx')
title('Elements in physical space');
xlabel('Max edge length');
ylabel('No. of elements');
Anurag Bhattacharjeehttps://kr.mathworks.com/matlabcentral/profile/authors/14932055anuragbhattacharjeetag:kr.mathworks.com,2005:Question/47693120190820T21:43:19Z20190820T22:02:24ZHow to change the name of an image?I have multiple images named as 10000, 10006, 10013, 100247 etc and I want to rename these images as 1_Gamma, 2_Gamma, 3_Gamma, 4_Gamma respectively. Any help would be appreciated. Thanks
oshawcolehttps://kr.mathworks.com/matlabcentral/profile/authors/9137511oshawcoletag:kr.mathworks.com,2005:Question/47692520190820T20:57:01Z20190820T22:02:03ZTranslating sigma notation / summation / series and integral equation from Microsoft Word into MATLAB syntax and graphing / plottingHello everybody,
I have a little trouble here. I trying to graph/plot the following equation with MATLAB. I already solved the integral of this equation:
f(t)=0.111627907+∑_(n=1)^∞▒〖(1/430 ∫_0^50▒〖((0.000003072(t25)^4+1.2) cos(2nπt/860) )dt(nπt/430))〗〗+∑_(n=1)^∞▒〖(1/430 ∫_0^50▒〖((0.000003072(t25)^4+1.2 ) sin(2nπt/860) )dt(nπt/430))〗〗
f(t)=0.111627907+∑_(n=1)^∞▒(1/430 1/((π)^4 n^4 ) (177504/5 (π)^2 n^2+7876917504/125)+1(π)^5 n^5 (177504/625 (6450(π)^2 n^2+3816336) sin(5/43 πn)17750462/5 (125(π)^3 n^3221880πn) cos(5/43 πn) )(nπt/430)) +∑_(n=1)^∞▒〖(1/430 1/((π)^5 n^5 )(45796032/25 (π)^2 n^2677414905344/625)+1/((π)^5 n^5 )(177504/625 (6450(π)^2 n^23816336)cos(5/43 πn)177504/625 (125(π)^3 n^3221880πn)sin(5/43 πn)(nπt/430))〗Taosui Lihttps://kr.mathworks.com/matlabcentral/profile/authors/15964429taosuilitag:kr.mathworks.com,2005:Question/47691420190820T18:47:25Z20190820T22:01:40ZHow to subtract two images in matlab?I have couple of images below which I want to subtract from each other. The images are taken from the same sample at different time frames. I want to notice the movement of the particles between those time frames. So I want to take out the part of the image that only contains the liquid particles. I want to subtract INTENSITY14.JPG from INTENSITY15.JPG. Ideally, the resultant image should look like SUBTRACT.JPG where the red dased box shows the part of the image which contains the liquid. But, I am getting the result as shown in S1.jpg which is undesirable. Below is my code. Any suggestions would be very much appreciated. Thank you.
a = imread('Intensity15.jpg');
b = imread('Intensity14.jpg');
dblSubtractedImage = double(a)  double(b);
imshow(dblSubtractedImage, []);
Warid Islamhttps://kr.mathworks.com/matlabcentral/profile/authors/9112730waridislamtag:kr.mathworks.com,2005:Question/47692720190820T21:27:49Z20190820T21:53:10Zismembertol does not work as documentedHello,
This function should work with absolute tolerance. Here is an example where it doesn't work as documented
B=[ 1.9500 1.0000];
A=[3.0000 2.0000 4.0000 2.5000 1.2000 1.1000];
[Loc1,Loc2]=ismembertol(B,A,0.1,'DataScale',1)
What should come out according to documentation is
Loc1 =
1×2 logical array
1 1
Loc2 =
2 6
What does come out however is
Loc1 =
1×2 logical array
1 0
Loc2 =
2 0
It seems someone forgot the absolute when comparing :) Bessam Al Jewadhttps://kr.mathworks.com/matlabcentral/profile/authors/14572167bessamaljewadtag:kr.mathworks.com,2005:Question/47676920190819T23:19:26Z20190820T21:48:45ZCan't get RTLSDR to work on 2017a on Win10... 'Error code 12'I'm trying to get an RTLSDR working with Matlab 2017a on Win10. My RTLSDR works fine with both SDRSharp and CubicSDR so the hardware is ok and I think I have the drivers set up correctly (I have WinUSB installed for both the BulkIn interfaces of the RTLSDR). My particular dongle is a 'NooElec NESDR Smart v4'. When I go through the Matlab setup for the RTLSDR Hardware Support package and click 'list devices', or when I just enter 'sdrinfo' on the Matlab console I get 'Error code 12'. Any idea what this means or how to fix it?Jay Khttps://kr.mathworks.com/matlabcentral/profile/authors/3548407jayktag:kr.mathworks.com,2005:Question/47677220190819T23:49:54Z20190820T21:43:31ZHow to solve this equation with two variables in one equation ? A = 1;
B = 1;
for n=0.0:0.1:1.0
for c = 0.0:0.1:1.0
c0 = 1.13e4;
w = A*(cc0)^2*(n^43*n^2+2*n)+B.*(c1)^2*n^2;
end
endRobert101https://kr.mathworks.com/matlabcentral/profile/authors/15984045robert101tag:kr.mathworks.com,2005:Question/47663020190819T04:26:39Z20190820T21:42:15ZHow select a first value from the binary matrix ?I have below matrix i want to select one value from each column which will be 1 make other 0 at return i will get 10*10 matrix.Selection of 1 such that a11 from 1st column,a22 from 2 column,a13 from the third column,a14 from the 4column and so on and make other value in the column 0.If we go for the indexing is ok for the small matrix but in bigger matrix we don't know the position of the 1 value.So is it possible to changed what i want.I have 1300*500 size matrix this is only for the example.
Thanks in advanced for your help.
matrix = [
0 1 0 0 1 0 0 1 0 1 0 1 1 1 0 1 0 0 1 0
1 1 0 0 1 1 1 0 0 1 0 1 0 1 0 0 1 1 1 1
0 1 1 0 0 1 1 0 1 1 1 0 0 1 1 0 0 0 1 1
0 1 1 1 1 1 1 0 0 0 0 1 0 1 1 0 0 0 1 0
1 1 0 0 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 1
0 0 0 0 0 1 0 0 1 0 1 1 0 1 1 1 1 1 1 0
1 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 0 1 0 1
1 1 0 0 1 0 1 0 0 0 0 0 1 1 0 1 1 1 0 1
1 0 1 0 0 1 0 0 1 0 0 0 0 1 1 0 0 0 1 0
0 0 1 0 1 0 1 1 0 0 0 1 1 0 0 0 1 1 0 1
];
vikash kumarhttps://kr.mathworks.com/matlabcentral/profile/authors/15825608vikashkumartag:kr.mathworks.com,2005:Question/12621820140418T10:32:18Z20190820T21:41:59ZPassing in a function as an argumentDear all,
I would like to write a Function Mfile f.m, which is to contain a primary function called f as well as two subfunctions called subFunc1 and subFunc2, respectively.
Within the primary function f, I need to call subFunc1; what is the proper syntax for passing subFunc2 as an input parameter to such a call of subFunc1?
Any feedback would be very much appreciated.
Regards,
KaloyanKaloyan Marinovhttps://kr.mathworks.com/matlabcentral/profile/authors/5263381kaloyanmarinovtag:kr.mathworks.com,2005:Question/47675220190819T20:32:59Z20190820T21:41:46Zmatlab table from for loopsfor iter = 1:2
Num_of_Banks = 4
Initial_Capitals = [ randi([0 100],Num_of_Banks,1) ]
Total_initial_caps = sum(Initial_Capitals)
end
This will set Num_of_Banks = always 4 and Initial_Capitals = rand
How can I create a table from X num of iterations (Prob = everything that I have tried til now) and store correctly the results?
Trying to make sth like this:
Num_of_Banks Initial_Capitals
4 amount 1
4 amount 2
4 amount 3
... ...
(My prog has almost 50 variables to be added so this is a small part of it)
Will appreciate your answers
(R2016a version)Antonio Grivashttps://kr.mathworks.com/matlabcentral/profile/authors/10990035antoniogrivastag:kr.mathworks.com,2005:Question/47683120190820T09:46:35Z20190820T21:41:45ZHow to insert grid lines specific position ? How to insert grid lines specific position ? check this attached Imafe? How to insert grid line inside red line box on image?
voxeyhttps://kr.mathworks.com/matlabcentral/profile/authors/12197859voxeytag:kr.mathworks.com,2005:Question/47592420190813T06:44:58Z20190820T21:40:39Zforcing try catch loop during using another script Hello People
I have a problem in try catch loop,
I have number of files and I analyze these files by calling another script which has the analysis code.
for example let's say in the main script I am writting as the following:
num_files=20
[filename, pathname] = uigetfile([strPathLife ... '\...\*.xlsx;*.xlsm'], .. 'ExcelFile auswählen',... 'MultiSelect','on') %this mean the first fiel would be file(1), file(2),... etc
for i=num_files
try
analysis_code(file(i)) % analysis_code is another script analyzes the data of the files
catch
disp('error')
end
end
according to this code it should analyze all the file disregarding if the there is error in analysing one file or more.
Thanks in advance
Ayman Mounirayman mounirhttps://kr.mathworks.com/matlabcentral/profile/authors/11511006aymanmounirtag:kr.mathworks.com,2005:Question/47693020190820T21:33:07Z20190820T21:33:07ZIssue with parameter array sorting in SimBiology after loading using sbioloadprojectWhen I load a .sbproj the parameters are often in seemingly random order. Consider the example model 'AntibacterialPKPD.sbproj'
s1 = sbioloadproject('AntibacterialPKPD');
model = s1.m1
model.Parameters
the parameter array looks like that
SimBiology Parameter Array
Index: Name: Value: ValueUnits:
1 KC50 1 microgram/milliliter
2 Kmax 3.5 1/hour
3 B 1.5 1/hour
4 CL 1 milliliter/minute
...
Is it possible to sort it alphabetically with respect to 'Name'?
The reason I am asking is that I would like to assign selected parameters read in from a file, e.g. containing different parameter sets for 3 parameters B, k1, k2.
% paramArray = [paramSet1; ...
% paramSet2 ;...
% paramSet3]
% with
% paramSeti = {B_i, k1_i, k2_i}, i = 1,2,3
Any ideas would be very appreciated.
Best, Memjeyhttps://kr.mathworks.com/matlabcentral/profile/authors/8885777emjeytag:kr.mathworks.com,2005:Question/47692220190820T20:32:47Z20190820T21:32:59Zsfit decimals output only 4 sig figsI have a code that fits coefficients of a polynomial to data. I can access these polynomial coefifcients that are fit through a variable that appears to be a 1x1 sfit. How do I display more decimals? Currently it just shows 4 sig figs. I tried format long but that did not do anything.
Any help would be appreciated!Benjaminhttps://kr.mathworks.com/matlabcentral/profile/authors/4307919benjamintag:kr.mathworks.com,2005:Question/47692320190820T20:45:05Z20190820T21:30:55Zhow to use >,< with while loopif i have a list of numbers and i have to use 'while' loop to determine when the list of numbers decreased by 10000 from initial value , how should i code it ?Navikesh Krishnahttps://kr.mathworks.com/matlabcentral/profile/authors/15809386navikeshkrishnatag:kr.mathworks.com,2005:Question/47692620190820T20:58:38Z20190820T21:28:54ZDo I need Matlab Runtime to run a 3rdparty application if I have Matlab standalone?The standalone version differs from a the required runtime version.AlexGhttps://kr.mathworks.com/matlabcentral/profile/authors/5467800alexgtag:kr.mathworks.com,2005:Question/47659620190818T16:06:31Z20190820T21:23:00ZHow to convert the text file (1x290400) to image as shown as below?
After I done simulatation, ModelSim gives me an output image file in text file format when doing the convolution neutral network.
However, the output image in text file is 1 column vector. (1x290400)
Community have an example codes to convert the 1 column vector text file to become an image like above (55x55x96)?There is 96 pictures in 1 output picture and each size is 55x55
Please help me and thank a lot..Tham Wei Jianhttps://kr.mathworks.com/matlabcentral/profile/authors/15051338thamweijiantag:kr.mathworks.com,2005:Question/47691120190820T18:23:56Z20190820T21:22:33ZHow can I limit the size of the output signal from deconvolution using deconvwnr?I want to deconvolve a signal with a point spread function to retrieve a "ground truth" signal. I know that the ground truth is roughly Gaussian and should be 7x7 pixels.
This works when I do deconvolution without noise. However, when I add noise I get this weird periodic semigaussian signal that is the same length as the point spread function (47 pixels).
Is it possible to restrict the size of the output to be a 7x7 image?
Here is the code. The variables are attached:
deconvwnr(temp,sptint,0)Benjamin Brennerhttps://kr.mathworks.com/matlabcentral/profile/authors/8322393benjaminbrennertag:kr.mathworks.com,2005:Question/47691320190820T18:32:50Z20190820T21:22:11Zwrite a function that takes any equation as an inputI saw that similar questions were asked previously by they were way too specific to be helpful for me.
I need to write a function that has inputs of a series of x values and an equation. This function should create an interpolating polynomial for this function using those given x values. It should then output the coefficients of this polynomial
My question is how do I write a function with an input of a function which outputs a matrix?
Code so far is just the one line:
function P(x) = splinecalc(Xlist, f(x))
And that line doesn't work. It should be able to take in things like sin(x) or x^3+15x4 or e^x, etc. and it should output a 4×n matrix giving the coefficients of the natural (free) cubic spline through the n+1 points . The columns of the output matrix should correspond to the n cubic polynomials, in order. The kth row of your output matrix should give the coefficients of . Konrad Brinehttps://kr.mathworks.com/matlabcentral/profile/authors/10992430konradbrinetag:kr.mathworks.com,2005:Question/45601520190412T13:15:16Z20190820T21:21:00Zfailed in using loaddap with matlab2017b on centOS 7 systemI need to download data from NCEP website with the opendap link of (https://nomads.ncep.noaa.gov:9090/dods/gfs_0p25/gfs20190409/gfs_0p25_00z)
the command "x=loaddap('A e +v ', fname)"
the system shows the error massage of:

If you are sseing this message, the copy of loaddap that matlab
tried to run was not compatible with your computer.
Please visit <a href="http://www.opendap.org/download">opendap.org</a> to get the correct version or
email support@opendap.org for help.
Error using loaddap (line 141)
Incompatible compiled matlab program installed.

I use the package of : https://www.opendap.org/deprecatedsoftware/matlabloaddap/3.7.3
by addapth addpath('/dataA/swan/prj.roms.opr.HM/loaddap3.7.3/')

How should I solve the problem? min hehttps://kr.mathworks.com/matlabcentral/profile/authors/14650394minhetag:kr.mathworks.com,2005:Question/47691820190820T19:41:52Z20190820T21:13:28Zrotation constraint in imregtformIs there a method to apply more explicit (e.g. not rigid/similarity/etc) constraints on the optimization in imregtform?
I have a video with periodic features that is rotating and translating. The use of 'rigid' in imregtform typically works when registering between frames. Occassionally, however, the optimized tform "skips" to the next set of features and rotates the registration by ~10 degrees. This causes errors for registerting subsequent (downstream) frames. Is there a way to limit the bounds on the optimization space? I can limit the search radius growth and number of iterations to control the final search radius, but end up severely restricting the number of iterations that can be performed.
Would one of the other image registration pipelines work better for this application? Image registration approaches shows intensitybased as the only one that supports both nonrigid (important for another part of the workflow) transforms and fully automatic (there are a lot of videos!) workflow. If another framework may work better, I'm definitely willing to try it.
Thanks in advance for your help!Brianhttps://kr.mathworks.com/matlabcentral/profile/authors/3060949briantag:kr.mathworks.com,2005:Question/47674920190819T20:23:18Z20190820T21:07:28Znonlinear fit of experimental data Dear MatLab Experts,
I would like to generate a nonlinear regression model to fit my experimental data 'Mk_Superf_FSF' as function of the independent variables 'MaxFDiam' and 'MinFDiam' which are respectively the max and min diameter of an arbirarily shaped closed and connected 2D surface. I also added the variable 'Area' which is obviously correlated to max and min diameters so I think it is not wise to use that as well.
I was suggested a linear fit for the experimental data (see attached picture). The 7th order polynomial p(x) fits the data very well but the suggested formula is non physical. In fact, the variable used is a sum of quantities with different units:
x = MaxFDiam * MinFDiam + Area / MaxFDiam + Area / MinFDiam + MaxFDiam / MinFDiam
I cannot assign a units to ithe resulting sum because the product of the two diameters has units [mm^2.] whereas the Area/MaxDIameter has units [mm], the ratio of the two diamters is unitless.
I tried to fit a sum of two negative exponentials where in the exponent I have the Area ad the product of the diameters respectively. MatLab complained printing out that the Jacobian has a column of all zeros. I tried some other combinations of exponential functions. Again MatLab complained stating that the model returns "NaN" of "Infinity".
Some other times MatLab printed out that that maximum number of iterations had been exceeded.
I tried a powerlaw fit as follows:
coeffs0 = [0.8672 1 1]
opts = statset('fitnlm');
opts.RobustWgtFcn = 'bisquare';
X = [MaxFDiam' MinFDiam'];
mdlfun = @(coeff, X) coeff(1)* X(:,1).*X(:,2).^coeff(2) + coeff(3);
mdl = fitnlm(X,Mk_Superf_FSF',mdlfun, coeffs0,'Options', opts, 'CoefficientNames', {'a' , 'b', 'c'});
This time MatLab did not complain but the resulting model is anything but good. The R^2 value is awful. The P_values are very high except for one.
mdl =
Nonlinear regression model:
y ~ a*x1*x2^b + c
Estimated Coefficients:
Estimate SE tStat pValue
________ ________ ________ __________
a 0.007407 0.02121 0.34922 0.73352
b 0.26657 0.87603 0.30429 0.76658
c 0.93603 0.048648 19.241 8.0919e10
Number of observations: 14, Error degrees of freedom: 11
Root Mean Squared Error: 0.0363
RSquared: 0.215, Adjusted RSquared 0.0721
Fstatistic vs. constant model: 1.51, pvalue = 0.264
Maybe the model is not right. Maybe the initial parameter values are not good.....
I would greatly appreciate some help at getting a decent fit. Above all, I would like to learn techniques to:
(1) devise the model formula
(2) choose the initial parameter values
Thank you so much for any suggestion and help.
Best regards,
Maura E. M.
Maura Monvillehttps://kr.mathworks.com/matlabcentral/profile/authors/13231254mauramonvilletag:kr.mathworks.com,2005:Question/10021220090627T01:11:00Z20190820T20:53:28ZHow do I extract an image from a PACS server using MATLAB?I would like to extract an image from a PACS server using MATLAB.
MathWorks Support Teamhttps://kr.mathworks.com/matlabcentral/profile/authors/4622813mathworkssupportteamtag:kr.mathworks.com,2005:Question/47692420190820T20:52:37Z20190820T20:52:37ZInvalid Transformation in trainNetwork (on pixelLabelImageDatastore)Hi
I am trying to do transfer learning on semantic segmentation with the Deep Learning Toolbox, however I am not sure if I am doing things right.
As I don't have a lot of training data, I am using vgg19 as basis, using 224x224 images. However the images and labels I created with ImageLabeler are of size 1200x1600. Thus I try to transform both the image and pixel label datastores to 224x224, but it doesn't seem to work.
The error I am getting is:
Error using trainNetwork (line 165)
Invalid transform function defined on datastore.
Caused by:
Error using nnet.internal.cnn.util.NetworkDataValidator/assertDatastoreHasResponses (line 120)
Invalid transform function defined on datastore.
Error using imresize
Expected input number 1, A, to be one of these types:
single, double, int8, int16, int32, uint8, uint16, uint32, logical
Instead its type was table.
Here is the code:
%prepare training data from ground truth
[imdsTrain,pxds] = pixelLabelTrainingData(gTruth);
%segnetLayers with e.g. vgg19
imageSize = [224 224 3];
numClasses = 2;
lgraph = segnetLayers(imageSize,numClasses,'vgg19');
%Create a pixel label image datastore for training a semantic segmentation network.
pximds = pixelLabelImageDatastore(imdsTrain,pxds);
%resize the labels and images
targetSize = [224,224];
imdsReSz = transform(pximds,@(x) imresize(x,targetSize));
%Set up training options.
options = trainingOptions('sgdm','InitialLearnRate',1e3, ...
'MaxEpochs',20,'VerboseFrequency',10);
%Train the network.
net = trainNetwork(imdsReSz,lgraph,options);
What am I doing wrong?Markus Esshttps://kr.mathworks.com/matlabcentral/profile/authors/5461537markusesstag:kr.mathworks.com,2005:Question/17929020150219T15:39:23Z20190820T20:45:34ZMerge tables with different dimensions? Hi,
I'm trying to use vertcat to add together a sequence of tables. The problem is, some are 24x22, some are 24x19, etc.
Matlab returns the error
Error using table/vertcat (line 56)
All tables in the bracketed expression must have the same number
of variables.
Is there a way to work around this? Like, adding empty columns?
Thanks so much.Chelseahttps://kr.mathworks.com/matlabcentral/profile/authors/5522099chelseatag:kr.mathworks.com,2005:Question/47692020190820T20:26:04Z20190820T20:42:12ZTraining and Testing data for GRNNI have a training program and a testing program for a Generalized Regression Neural Network.
The result of the training program is the same as the input which it should be. The final answer is "poutput". After the row of percent signs, I have the testing program. For some reason, all 259 values for one row are the same (which it sould not be and the values for all rows should be different). I'm not sure if it is something to do with the program or something I did.
%% Using train_FD002 dataset, 1) Cluster Data, 2) Fit Exp Model 3) Train Network
% Load training data structure
clear all %#ok<CLALL>
load('train_FD002_eng')
%% ~~ KMeans Separation  trainFD002~~
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%% Merge All trainFD002 Data and Cluster by Operational Setting
opsset_groups = [];
for i = 1:length(train_FD002_eng) % One for each engine
engine = i*ones(length(train_FD002_eng(i).cycle),1);
cycle = train_FD002_eng(i).cycle;
opsset = train_FD002_eng(i).opsset;
sensor = train_FD002_eng(i).sensor;
opsset_groups = [opsset_groups; engine cycle opsset sensor]; %#ok<AGROW>
end; clear i
idx = kmeans(opsset_groups(:,3:5),6);
% clear engine cycle opsset sensor
%% Reassemble into Structure by Clusters
for i=1:max(idx) % #clusters
train_FD002_clust(i).eng = opsset_groups(idx==i,1); %#ok<SAGROW>
train_FD002_clust(i).cycle = opsset_groups(idx==i,2); %#ok<SAGROW>
train_FD002_clust(i).opsset = opsset_groups(idx==i,3:5); %#ok<SAGROW>
train_FD002_clust(i).sensor = opsset_groups(idx==i,6:26); %#ok<SAGROW>
end
% clear i idx opsset_groups
%% Plot Clustered Data
for i=1:6
plotCMAPPS(train_FD002_clust(i),['FD002 Cluster ', num2str(i),' Data']);
end; clear i
%% ~~Generate Best Fit Exponential for Each Engine~~
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%% Sensors that display Ae^(Bt)+C behavior (health indicies) (11)
HI = [2 3 4 7 8 9 11 12 13 14 17];
% Generalized exponential function
expfun = @(C,cyc)C(1)*exp(C(2)*cyc)+C(3);
%% Preallocate Cell Array for Fit Parameters
C_all = cell(6,1); % A separate cell for each cluster
% C_all contains ( EngineNumber(260) x FitParameters(3) x HIs(11) )
for i=1:6; C_all{i} = zeros(260,3,length(HI)); end; clear i
%% Fit Ae^(Bt)+C for each engine trajectory
fail_cycle = zeros(260,6); % Array containing final cycles for each engine
opts = optimset('Display','off'); % supress lsqcurvefit output
for i=1:6 % each cluster (6)
tic
for j=1:260 % each engine (260)
all_eng_j = train_FD002_clust(i).eng==j; % indecies for just engine j
cycle = train_FD002_clust(i).cycle(all_eng_j); % extract engine j cycles
fail_cycle(j,i) = max(cycle); % record failure cycle
for k=1:length(HI) % each HI sensor (11)
sensor = train_FD002_clust(i).sensor(all_eng_j,HI(k)); % extract sensor data
C = lsqcurvefit(expfun,[0 0 0],cycle,sensor,[1000 0 0],[],opts); % determine exponential fit parameters
C_all{i}(j,:,k) = C; % add to library of fit paramters
end
end
toc
end; clear i j k
fail_cycle1 = max(fail_cycle,[],2);
% clear m opts all_eng_j C cycle sensor
%% Overlay Exponential Fits on Cluster Plots
for i=1:6 % each cluster (6)
for j=1:length(HI) % each HI (11)
figure(i); subplot(5,5,3+HI(j)) % focus on sensor axis
y_lim = ylim; % extract yaxis limits
for k=1:260 % each engine (260)
fitline = expfun(C_all{i}(k,:,j),0:400); % best fit exp points
plot(0:400,fitline,'g') % plot best fit exp points
end
ylim(y_lim) % reset yaxis limits
end
end; clear i j k
% clear fitline y_lim HI expfun
%% Use data for a General Regression Neural Network
for i=1:6
for j=1:11
Input=(C_all{i,1}(:,:,j))';
Target=fail_cycle1';
Input_all{i,j}=Input;
Norm_all{i,j}=Target;
end
end
for i=1:6
for j=1:11
input_all{i,1}=[Input_all{i,1};Input_all{i,2};Input_all{i,3};...
Input_all{i,4};Input_all{i,5};Input_all{i,6};Input_all{i,7};...
Input_all{i,8};Input_all{i,9};Input_all{i,10};Input_all{i,11}];
target_all{i,1}=Norm_all{i,1};
end
end
%Create Neural Networks of all Health Indicators for all 6 Clusters.
net1=newgrnn(input_all{1,1},target_all{1,1},0.01);
net2=newgrnn(input_all{2,1},target_all{2,1},0.01);
net3=newgrnn(input_all{3,1},target_all{3,1},0.01);
net4=newgrnn(input_all{4,1},target_all{4,1},0.01);
net5=newgrnn(input_all{5,1},target_all{5,1},0.01);
net6=newgrnn(input_all{6,1},target_all{6,1},0.01);
chrisnet1=net1;
chrisnet2=net2;
chrisnet3=net3;
chrisnet4=net4;
chrisnet5=net5;
chrisnet6=net6;
save chrisnet1
save chrisnet2
save chrisnet3
save chrisnet4
save chrisnet5
save chrisnet6
poutput1=sim(chrisnet1,input_all{1,1});
poutput2=sim(chrisnet2,input_all{2,1});
poutput3=sim(chrisnet3,input_all{3,1});
poutput4=sim(chrisnet4,input_all{4,1});
poutput5=sim(chrisnet5,input_all{5,1});
poutput6=sim(chrisnet6,input_all{6,1});
poutput={poutput1;poutput2;poutput3;poutput4;poutput5;poutput6};
for i=1:6
HI=[Norm_all(1,1);Norm_all(1,2);Norm_all(1,3);Norm_all(1,4);...
Norm_all(1,5);Norm_all(1,6);Norm_all(1,7);Norm_all(1,8);...
Norm_all(1,9);Norm_all(1,10);Norm_all(1,11)];
HI_sensor{i,1}=cell2mat(HI);
%Measure Absolute Errors
Errors=(poutput{i,1}HI_sensor{i,1});
Squared_Error=Errors.^2;
MSE=mean(Errors.^2); %Mean Squared Error
RMSE(i,:)=sqrt(MSE); %Root Mean Squared Error. Horizontal
%indicates 260 points for each induvidual sensor measurement for
%all six clusters
end
% clear i j k Errors fail_cycle1 Input MSE NormFact NormInputt poutput Target
% clear Squared_Error TargetFact TargetNorm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Using test_FD002.txt, 1) Cluster Data, 2) Fit Exp Model 3) Test Network
% Load testing data structure. "t" denotes testing values
clear all %#ok<CLALL>
opsset_groupst=load('test_FD002.txt');
RUL=load('RUL_FD002.txt');
%load neural networks
load chrisnet1
load chrisnet2
load chrisnet3
load chrisnet4
load chrisnet5
load chrisnet6
%% Run kmeans and reassemble into clusters
idxt = kmeans(opsset_groupst(:,3:5),6);
for i=1:max(idxt) % #clusters
test_FD002_clustt(i).eng = opsset_groupst(idxt==i,1); %#ok<SAGROW>
test_FD002_clustt(i).cycle = opsset_groupst(idxt==i,2); %#ok<SAGROW>
test_FD002_clustt(i).opsset = opsset_groupst(idxt==i,3:5); %#ok<SAGROW>
test_FD002_clustt(i).sensor = opsset_groupst(idxt==i,6:26); %#ok<SAGROW>
end
% clear i idxt opsset_groupst
%% Plot Clustered Data
for i=1:6
plotCMAPPS(test_FD002_clustt(i),['FD002 Cluster ', num2str(i),' Data']);
end; clear i
%% ~~Generate Best Fit Exponential for Each Engine~~
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%% Sensors that display Ae^(Bt)+C behavior (health indicies) (11)
HIt = [2 3 4 7 8 9 11 12 13 14 17];
% Generalized exponential function
expfunt = @(Ct,cyc)Ct(1)*exp(Ct(2)*cyc)+Ct(3);
%% Preallocate Cell Array for Fit Parameters
C_allt = cell(6,1); % A separate cell for each cluster
% C_all contains ( EngineNumber(260) x FitParameters(3) x HIs(11) )
for i=1:6; C_allt{i} = zeros(259,3,length(HIt)); end; clear i
%% Fit Ae^(Bt)+C for each engine trajectory
fail_cyclet = zeros(259,6); % Array containing final cycles for each engine
optst = optimset('Display','off'); % supress lsqcurvefit output
for i=1:6 % each cluster (6)
tic
for j=1:259 % each engine (259)
all_eng_jt = test_FD002_clustt(i).eng==j; % indecies for just engine j
cyclet = test_FD002_clustt(i).cycle(all_eng_jt); % extract engine j cycles
if length(cyclet)<3; continue; end % check for at least 3 cycles
fail_cyclet(j,i) = max(cyclet); % record failure cycle
for k=1:length(HIt) % each HI sensor (11)
sensort = test_FD002_clustt(i).sensor(all_eng_jt,HIt(k)); % extract sensor data
Ct = lsqcurvefit(expfunt,[0 0 0],cyclet,sensort,[1000 0 0],[],optst); % determine exponential fit parameters
C_allt{i}(j,:,k) = Ct; % add to library of fit paramters
end
end
toc
end; clear i j k
fail_cycle1t = max(fail_cyclet,[],2);
% fail_cycle1t=fail_cycle1t+RUL;
% clear mt optst all_eng_jt Ct cycle sensort
%% Overlay Exponential Fits on Cluster Plots
for i=1:6 % each cluster for testing data only(6)
for j=1:length(HIt) % each HI (11)
figure(i); subplot(5,5,3+HIt(j)) % focus on sensor axis
y_limt = ylim; % extract yaxis limits
for k=1:259 % each engine (259)
fitlinet = expfunt(C_allt{i}(k,:,j),0:400); % best fit exp points
plot(0:400,fitlinet,'g') % plot best fit exp points
end
ylim(y_limt) % reset yaxis limits
end
end; clear i j k
% clear fitlinet y_limt HIt expfunt
%% Use data for a General Regression Neural Network
for i=1:6
for j=1:11
Inputt=(C_allt{i,1}(:,:,j))';
Targett=fail_cycle1t';
Input_allt{i,j}=Inputt;
Norm_allt{i,j}=Targett;
end
end
for i=1:6
for j=1:11
input_allt{i,1}=[Input_allt{i,1};Input_allt{i,2};Input_allt{i,3};...
Input_allt{i,4};Input_allt{i,5};Input_allt{i,6};Input_allt{i,7};...
Input_allt{i,8};Input_allt{i,9};Input_allt{i,10};Input_allt{i,11}];
target_allt{i,1}=Norm_allt{i,1};
end
end
%input testing data
poutput1t=sim(chrisnet1,input_allt{1,1});
poutput2t=sim(chrisnet2,input_allt{2,1});
poutput3t=sim(chrisnet3,input_allt{3,1});
poutput4t=sim(chrisnet4,input_allt{4,1});
poutput5t=sim(chrisnet5,input_allt{5,1});
poutput6t=sim(chrisnet6,input_allt{6,1});
poutputt={poutput1t;poutput2t;poutput3t;poutput4t;poutput5t;poutput6t};
for i=1:6
HIt=[Norm_allt(1,1);Norm_allt(1,2);Norm_allt(1,3);Norm_allt(1,4);...
Norm_allt(1,5);Norm_allt(1,6);Norm_allt(1,7);Norm_allt(1,8);...
Norm_allt(1,9);Norm_allt(1,10);Norm_allt(1,11)];
HI_sensort{i,1}=cell2mat(HIt);
%Measure Absolute Errors
Errorst=(poutputt{i,1}HI_sensort{i,1});
Squared_Errort=Errorst.^2;
MSEt=mean(Errorst.^2); %Mean Squared Error
RMSEt(i,:)=sqrt(MSEt); %Root Mean Squared Error. Horizontal
%indicates 260 points for each induvidual sensor measurement for
%all six clusters
end
poutputt_full=cell2mat(poutputt);
fout=mean(poutputt_full);
% clear i j k Errors fail_cycle1 Input MSE NormFact NormInputt poutput Target
% clear Squared_Error TargetFact TargetNorm
Chris Basichttps://kr.mathworks.com/matlabcentral/profile/authors/9630081chrisbasictag:kr.mathworks.com,2005:Question/47689120190820T16:30:45Z20190820T20:38:31ZPhasor plot representation sinusoidal Hi,
I'm trying to plot in a phasor rapresentation current data acquired from CTs in a real 3p circuit.
I have access to the data in a txt file, currently I'm just plotting the three sinusoidal components in time domain, but I'd like to have a phasor representation to see theirphase shift.
Is there an easy why to do it? I've tried compass but it gives weird results. Thanks.
MarcoMarco Bosihttps://kr.mathworks.com/matlabcentral/profile/authors/8221871marcobositag:kr.mathworks.com,2005:Question/47691720190820T19:39:50Z20190820T20:37:14Zhelp to convert text file symbol into arrayHi i have this text file :
4c07b] IF hit state: 5 (S) valid: 1 writable: 0 readable: 1 dirty: 0 tag: 260
243240500: system.cpu00.icache: ReadReq [4c078c:4c078f] IF hit state: 5 (S) valid: 1 writable: 0 readable: 1 dirty: 0 tag: 260
243241000: system.cpu00.icache: ReadReq [4c0780:4c0783] IF hit state: 5 (S) valid: 1 writable: 0 readable: 1 dirty: 0 tag: 260
How convert each symbole in row into array ?
for example :
4c07b] IF ==== 4 = i[1,1]
c=i[1,2]
0= i[1,3]
7= [1,4]
b=i[1,5]
] =i[1,6]
....m
Furat Alobaidyhttps://kr.mathworks.com/matlabcentral/profile/authors/6214076furatalobaidytag:kr.mathworks.com,2005:Question/47666420190819T09:28:50Z20190820T20:36:34ZError in audio uploading time.Hi,
I am uploading an audio signal of 3 seconds in matlab, but after uploading it is showing 0.5 seconds audio and the signal is totally change. How can I change the time, so that I can listen full audio of 3 seconds and implement other operation on my 3 seconds audio. Please guide me.
Thanks in advance.
Sumair Hassanhttps://kr.mathworks.com/matlabcentral/profile/authors/14547944sumairhassantag:kr.mathworks.com,2005:Question/47676420190819T22:55:40Z20190820T20:35:32Zhow to solve matrix differential equationhi,
I' m trying to solve this differential equation for education purposes but I'm having difficulty to solve it.
does someone know a simple way to solve it?
𝑀 ∗ 𝑒̈ = 𝑄𝑣 − (𝐾𝑙 + 𝐾𝑡) ∗ 𝑒
I attached a pdf where you can find all the information about the program.
thank you very much.riccardo carrierihttps://kr.mathworks.com/matlabcentral/profile/authors/12306088riccardocarrieritag:kr.mathworks.com,2005:Question/47691620190820T19:26:35Z20190820T20:33:50ZRun a code for several valuesHello Friends,
Is there any way to run the program with multiple variable inputs and get the multiple corresponding data outputs and save them to Excel.
Example:
(I declare Rows and Columns variable in begining of the program)
Rows=100;
Columns=100;
(When code is run obtain outputs of Price and Energy)
Price=X1
Energy=Y1
I need some way to change the values of Rows and Columns bt 50 Increments (100,150,200,250,300,350......) to obtain the corresponding values of Price and Energy(X1,X2,X3,X4......;Y1,Y2,Y3,Y4........)
I want these to be automatically changing,not manually entering the 50 increment values.
venkat siddhartha ramahttps://kr.mathworks.com/matlabcentral/profile/authors/12798231venkatsiddhartharamatag:kr.mathworks.com,2005:Question/47638320190816T10:33:22Z20190820T20:32:27ZFinding minimum points in a plot.I want only the minimum points in the blue plot. I want an almost parabolic curve open downwards. ' islocalmin ' and , 'envelope' functions are not woking. How could I acheive it?
the orange plot is it's Savitzky–Golay filter output.
Abhiraj Guptahttps://kr.mathworks.com/matlabcentral/profile/authors/15711694abhirajguptatag:kr.mathworks.com,2005:Question/35528620170901T04:00:00Z20190820T20:31:15ZHow to give multiple inputs to the train function of Neural Network?I am creating a neural network in MATLAB and am trying to feed it multiple inputs. How do I define the inputs and feed them into the network? If input 1 is some matrix of numbers and input 2 is another matrix of numbers, how do I correctly define both inputs? And then how do I feed them into the network?
For example, if I do "train(net,input,target)", then how do I send all of the inputs?
Also, how do I connect both the input blocks to the network?
MathWorks Support Teamhttps://kr.mathworks.com/matlabcentral/profile/authors/4622813mathworkssupportteamtag:kr.mathworks.com,2005:Question/47680320190820T07:12:03Z20190820T20:31:00ZPolyspace 2017b new features over 2016aHello Team,
Could you please share exact updates between in polyspace 2016a and 2017b .
In POlyspace 2017b both the code prover and bug finder has been combined
one more question what are the pre requests for the polyspace 2017b
in Report geneartion how to export the results of the codeprover to excel for analysis
as we see only 3 options are available
Thank you for the support and answersGeetha Shttps://kr.mathworks.com/matlabcentral/profile/authors/15799557geethastag:kr.mathworks.com,2005:Question/47689720190820T17:30:26Z20190820T20:29:02ZHow to remove/rename part of a file name in a loop?Hi,
I am trying to rename 50,000 images that have an incorrect file name. They are all .tif files with a name similar to "Hoverdofeightnosleevetriggered000002.T000.D000.P000.H000.LA" and should be named like this "Hoverdofeightnosleevetriggered000001A". The files start at 0 and increase from there. Everyother photo is called A or B. Can someone please help me rename them in a loop?
I have looked online and can't seem to find a code that will work.
Thanks in advance! Monique Emburyhttps://kr.mathworks.com/matlabcentral/profile/authors/14608780moniqueemburytag:kr.mathworks.com,2005:Question/47692120190820T20:28:52Z20190820T20:28:52ZHow to plot data samples in three dimensions? I got a radar data cube for a fmcw radar. The rows represent the data for one chrip, the columns four receive antennas and the third dimension the number of chirps I model. Now I want to plot the chirp of one receive antenna in xyplane and all the chirps of one receive antenna in the zdomain spaced apart.
It should look something like that (without the rotation, n would be the time, m the number of chirps stored in third dimension and the amplitude is y)
Thank you for any suggestionsRobert_https://kr.mathworks.com/matlabcentral/profile/authors/9137395robert_tag:kr.mathworks.com,2005:Question/957220110615T18:50:12Z20190820T20:26:07Zkeep figures from popping up when running.I am doing a lot of batch processing in which I creating many figures. I would like to keep these figures in the background while running the Matlab code without the Figure window popping up each time a new figure is created. Is there an easy way to do this?
When the figure pops up it disrupts anything else you are doing on the computer.Michael Marcushttps://kr.mathworks.com/matlabcentral/profile/authors/910744michaelmarcustag:kr.mathworks.com,2005:Question/47659020190818T14:49:22Z20190820T20:24:28Z ERROR came as "Index exceeds matrix dimensions".%% When I incorporate 3 eqns, ERROR came as "Index exceeds matrix dimensions".
%%Here I have initial condition f=[0 0 0 ], BC: gl=[coswt t t], gr =[0 0 0 ].
What next?
Here is my trial:
H=10;R=5;Pr=1;G1=5;G2=5;Kc=1;Sc=0.22;wt=pi/2;Q=H(R/Pr);
xl=0; xr=5; % x domain [xl,xr]
J = 10; % J: number of division for x
dx = (xrxl)/ J; % dx: mesh size
tf = 01; % final simulation time
Nt = 100; % Nt: number of time steps
dt = tf/Nt;
mu = dt/(dx)^2;
% Evaluate the initial conditions
x = xl : dx : xr; % generate the grid point
% f(1:J+1) since array index starts from 1
f1 = 0;f2 = 0;f3 = 0; %%%I.C
% store the solution at all grid points for all time steps
u = zeros(J+1,Nt);
v = zeros(J+1,Nt);
w = zeros(J+1,Nt);
U=[u; v; w];
% Find the approximate solution at each time step
for n = 1:Nt
t = n*dt; % current time
% boundary condition at left side
gl = [cos(wt); t; t];
% boundary condition at right side
gr = [0; 0; 0];
if n==1 % first time step
for j=2:J % interior nodes
u(j,n) = (1+dt*Q)*f1(j) + dt*(G1*f2(j)+G2*f3(j))+mu*(f1(j+1)2*f1(j)+f1(j1));
v(j,n) = (1+dt*Q)*f2(j) + (mu/Pr)*(f2(j+1)2*f2(j)+f2(j1));
w(j,n) = (1dt*Kc)*f3(j) + (mu/Sc)*(f3(j+1)2*f3(j)+f3(j1));
U=[u(j,n) v(j,n) w(j,n)];
end
U(1,n) = gl; % the leftend point
U(J+1,n) = gr; % the rightend point
else
for j=2:J % interior nodes
u(j,n)= (1+dt*Q)*u(j,n1)+ dt*(G1*v(j,n1)+G2*w(j,n1))+ mu*(u(j+1,n1)2*u(j,n1)+u(j1,n1));
v(j,n)= (1+dt*Q)*v(j,n1)+ (mu/Pr)*(v(j+1,n1)2*v(j,n1)+v(j1,n1));
w(j,n)= (1+dt*Q)*w(j,n1)+ (mu/Sc)*(w(j+1,n1)2*w(j,n1)+w(j1,n1));
U=[u(j,n) v(j,n) w(j,n)];
end
U(1,n) = gl; % the leftend point
U(J+1,n) = gr; % the rightend point
end
end
% Plot the results
tt = dt : dt : Nt*dt;
figure(1)
plot(x,u)
hold onMINATI PATRAhttps://kr.mathworks.com/matlabcentral/profile/authors/12692023minatipatratag:kr.mathworks.com,2005:Question/47691920190820T19:49:18Z20190820T20:21:11ZTaking middle 4 values of n size arrayI know how to take the first 4 values of an n size array (1:4)
and the last 4 (end4:end)
but how would I take the middle 4 values of an n size array no matter the length?
ThanksJames Morrishttps://kr.mathworks.com/matlabcentral/profile/authors/14890179jamesmorristag:kr.mathworks.com,2005:Question/47668920190819T12:19:01Z20190820T20:17:30ZHow to bypass error message and continue (Using C++ executable in MATLAB)?I have a need to run the C++ executable from a for loop in MATLAB. I have written the following piece of code for the purpose,
clc
clear all
close all
EqNumbers = [17 18 20 21 22 23];
for i = 1:length(EqNumbers)
EqNumber = EqNumbers(i);
WriteRunE_File(EqNumber);
filename=['RunE_1.tcl'];
system(['OpenSees.exe<',filename]);
disp('An error occurred in Equke');
disp('Execution will continue.');
end
It is working fine most of the times, however, sometimes debug errors (like the one shown below) will appear. It is prompting me for action, if I press the "Abort" button then the program will continue for the next iteration. I just want to make this process automated, every time manually pressing the abort button is not possible for me, because there are more than 1000 iteartions in the program.
I tried using trycatch end as follows, but it did not serve the purpose.
clc
clear all
close all
EqNumbers = [17 18 20 21 22 23];
for i = 1:length(EqNumbers)
try
% Code to be executed goes here.
EqNumber = EqNumbers(i);
WriteRunE_File(EqNumber);
filename=['RunE_1.tcl'];
system(['OpenSees.exe<',filename]);
catch
disp('An error occurred in Equke');
disp('Execution will continue.');
end
end
I am searching for a way to bypass the error message or automatically press the "Abort" button. So that the program will move to the next iteration automatically.
Note:
I don't have access to the c++ source code (all I have is executable), hence I cannot update the value of CitaR. That's why I am looking for a workaround in MATLAB.
Thanks...
Learnerhttps://kr.mathworks.com/matlabcentral/profile/authors/8311989learnertag:kr.mathworks.com,2005:Question/25469020151113T05:00:00Z20190820T20:17:28ZHow can I display a MATLAB table in a figure?I have a MATLAB table where each of the variables contains a single column of data. How can I display the table in a figure?
MathWorks Support Teamhttps://kr.mathworks.com/matlabcentral/profile/authors/4622813mathworkssupportteam