https://jp.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — 新規の質問2019-10-19T05:40:39Ztag:jp.mathworks.com,2005:Question/4862432019-10-19T05:40:39Z2019-10-19T05:40:39ZLow memory while running code inspectorHi, I am using Matlab 2012 b and facing the below issue.
For 2 of my simulink models while generating code inspector report, Windows is showing "Low memory" and closing Matlab (refer attached message).
For other models in my project this is not happening. Below is my systems configuration
Processor: Intel® Xenon(R) CPU E3-1220 v5 3.00 GHz
Installed RAM : 32 GB
System Type : 64 bit operating system.
Hard disk Space free : 71 GB
What could be the reason behind this?Varun Nayyarhttps://jp.mathworks.com/matlabcentral/profile/authors/16607399-varun-nayyartag:jp.mathworks.com,2005:Question/4862292019-10-19T01:27:17Z2019-10-19T05:30:13ZHelp with using summation functions in matlab (Trying to create an atomic scatter function)Hello, I am trying to create a matlab script that calculates an atomic scattering factor dependent on a,b,s,z where z is the atomic number, a and b are a 4 term array I will be getting from my course textbook, and s is sin(theta)/lambda which I will be calculating by hand as part of my homework. Not sure why I am having this difficulty but it seems my matlab is much ruster than I thought, but I would rather do this than an excel spreadsheet.
Equation should look something like:
My code currently looks like this:
function f = f(z,s,a,b)
f =(z^2)-41.78214*(s.^2)*symsum(a.*(exp(1).^-b.*(s.^2)),[a,b],[1 4]);
end
Varaible are curently:
When I remove the summation I get an answer (woohoo!), but when i try to use the summation it really gives me the error:
>> Scatteringfactor(z,s,a,b);
Error: File: Scatteringfactor.m Line: 3 Column: 67
Unbalanced or unexpected parenthesis or bracket.
I suspect I am misusing the symsum function or there is a smarter way of doing this.Clifton Whittakerhttps://jp.mathworks.com/matlabcentral/profile/authors/14783686-clifton-whittakertag:jp.mathworks.com,2005:Question/4860742019-10-18T08:55:40Z2019-10-19T05:25:52Zhow to calculate mse and psnr of compressed video?I want to calculate mse and psnr of compressed video?
thankyouToan Nguyenhttps://jp.mathworks.com/matlabcentral/profile/authors/11222062-toan-nguyentag:jp.mathworks.com,2005:Question/4862422019-10-19T05:21:13Z2019-10-19T05:21:13ZHow to remove glitch artifact from image ?Hi
I removed the criss-cross artifact in this image (below) using the code below. The code i used remves the noise in frequency domain. However, am wondering, can i correct this artifact in the special domain
LS=imread('MRIjpg');
LS=rgb2gray(LS);
figure(1);imshow(LS);title('Original')
f=fft2(LS);
fm=fftshift((f));
sd1=log(abs(fm));
figure(3), imagesc(sd1);title('FFT space')
Fm=fft2(LS);
Fm1=fftshift(Fm);
Fm1(440:460,320:340)=0;
Fm1(380:400,380:400)=0;
figure(2), imagesc(log(abs(Fm1)));title('FFT Filter')
ND=abs(ifft2(Fm1));% adjusting the inverse of the fft image
figure(3), imagesc(ND); title('output')
colormap('gray')%
Ahmad Alenezihttps://jp.mathworks.com/matlabcentral/profile/authors/15695060-ahmad-alenezitag:jp.mathworks.com,2005:Question/4861932019-10-18T17:55:00Z2019-10-19T05:19:21ZChanging x-axis following use of fit and plotI am using fit as described in https://www.mathworks.com/help/curvefit/fit.html to fit and plot a timestamp (in seconds from a base epoch) vs. data along with the fit and confidence values. I can't copy/paste results unforunately so this will have to be descriptive.
% timestamp = 1d array of doubles: seconds elapsed since 1/1/1970; ~1.57E9 sec
% data = 1d array of doubles: one data point per timestamp point; ~1E-10
curvefit = fit(timestamp, data, 'poly1', 'normalize','on'); % Generate fit
plot(curvefit, timestamp, data, 'o', 'predfunc') ; % Generate plot showing data, fit, and confidence bounds
For the plot, I'd like the x-axis to be dates. I can convert the timestamp to a datestamp using
datestamp = datetime(timestamp, 'ConvertFrom', 'epochtime', 'Epoch', epoch) ; % with epoch defined elsewhere
I tried getting the axis limits for the gcf and updating:
lim = axis;
axis( [datestamp(1) datestamp(end) lim(3) lim(4)] ); % Change x-axis, keep y-axis
The error message says all inputs must be datetimes, date/time character vectors, or date/time strings.
I tried xlim per https://www.mathworks.com/help/matlab/ref/xlim.html
xlim([datestamp(1) datestamp(end)])
The error message says that xlim requires numeric inputs.
Interestingly, I can generate a data vs. datestamp plot:
plot(datestamp, data,'o')
but this does not have the benefit of autogenerated fits, confidence bounds, and legends.
I'm missing something simple...
OldGuyInTheClubhttps://jp.mathworks.com/matlabcentral/profile/authors/16533361-oldguyintheclubtag:jp.mathworks.com,2005:Question/3525232017-08-12T09:39:24Z2019-10-19T05:18:45ZZero-crossing calculationHi all,
I need a script which can calculate zero crossing of the signal. I have the value of x and y.
The script should be able to calculate the exact position of zero crossing points. Help!Jayanta Debhttps://jp.mathworks.com/matlabcentral/profile/authors/9677149-jayanta-debtag:jp.mathworks.com,2005:Question/4862412019-10-19T05:00:00Z2019-10-19T05:13:54ZHow to find minimum number of largest square of 1 in an 2D bool matrixI have a 2D bool image (dimension 15x15) with several irregular regions black(mainly in the middle) and other pixes white(mainly in the outer part).
Is there a way to split the white region into square pieces as large as possible, and get the position and size for each square?
Thanks.
raymhttps://jp.mathworks.com/matlabcentral/profile/authors/8743272-raymtag:jp.mathworks.com,2005:Question/4862352019-10-19T03:25:18Z2019-10-19T04:56:16ZRegression on multiple variables in Matlab TimetableI have two matlab timetables that I'm attempting to perform regressions on. The first is a set of daily returns for the S&P 1500 where the variables are the included stocks. The second is a timetable containing the daily returns of the benchmarks I wish to regress against.
What I'm wondering is a more procedural question. I'm new to matlab. Is there a way that I can regress ALL the variables in my S&P 1500 timetable on a yearly basis (I'll be regressing against weekly returns, which I'm comfortable producing) without running through a loop for all the variables (i.e. can I regress them all one year at a time vs the same benchmark)?
Any help would be appreciated. I can do it through the looping process, but I'd like to avoid them wherever I can.
Let me know if more information is needed. Jason Teedhttps://jp.mathworks.com/matlabcentral/profile/authors/3942202-jason-teedtag:jp.mathworks.com,2005:Question/4862402019-10-19T04:52:50Z2019-10-19T04:52:50ZHow do I save handles struct from a GUI as a .txt file in a way I can then uploaded back to the GUI?I want to save my GUI data into a .txt file and then be able to upload that .txt file again to my GUI. I know I can use a .mat file, but I really want to use the .txt file.Jose Colonhttps://jp.mathworks.com/matlabcentral/profile/authors/15927069-jose-colontag:jp.mathworks.com,2005:Question/4858442019-10-17T08:54:39Z2019-10-19T04:47:19Z画像の長手方向の最長距離と短手方向の最長距離を出す構文について、実際の値としての pix の値を用いずにピクセル値で算出する方法はありますか。"画像の長手方向の最長距離と短手方向の最長距離を出すにはどうすればよいですか(以下の構文)" という質問への回答において、構文の中に"pix" が使用されていますが、これについてですが、比較のためのデータとして、"tatemax"である最長距離を算出したいと考えています。
方法はありますか？
%%画像入力
kaki_img=imread('EDGE1.bmp');
figure(2)
imshow(kaki_img)
title('kaki image');
%%画像全体のセグメンテーション
kaki_red=kaki_img(:,:,1);
figure(3)
imshow(kaki_red)
title('kaki red plane');
%%画像の二値化
thresh=graythresh(kaki_red);
kaki_th=imbinarize(kaki_red,thresh);
figure(4)
imshow(kaki_th);
title('kaki_th');
%%二値化画像の穴埋め
kaki_th=imfill(kaki_th,'holes');
figure(5)
imshow(kaki_th);
title('kaki_th(内部の穴埋め1回目）');
%%モルフォロジー処理
kaki_th=bwmorph(kaki_th,'remove');
figure(6)
imshow(kaki_th);
title('kaki_th(外周をプロット）');
%%モルフォロジー処理 膨張
kaki_th=imdilate(kaki_th,strel('disk',10));
figure(7)
imshow(kaki_th);
title('kaki_th(プロットした点を線で繋ぐ）');
%%モルフォロジー処理 画像の塗りつぶし
kaki_th=imfill(kaki_th,'holes');
figure(8)
imshow(kaki_th);
title('kaki_th(線内部の塗りつぶし）');
%%モルフォロジー処理 収縮
kaki_th=imerode(kaki_th,strel('disk',10));
figure(9)
imshow(kaki_th);
title('kaki_th(画像の収縮）');
%%二値化画像のクリーンアップ（周囲の白を除去）
cc1=bwconncomp(kaki_th);
main1=regionprops(cc1,'Area');
A=[main1.Area];
[~,biggest]=max(A);
kaki_th(labelmatrix(cc1)~=biggest)=0;
figure(10)
imshow(kaki_th);
title('kaki_th(周囲のノイズ除去)');
%%画像のエッジ検出
kaki_th_edge=edge(kaki_th);
figure(13)
imshow(kaki_th_edge);
[row,col]=find(kaki_th_edge);
for k=1:330
for i=k+1:330
I=((row(k)-row(i)).^2);
J=((col(k)-col(i)).^2);
dist=sqrt(I+J);
distmax=max(dist);
end
Distmax=max(distmax);
end
bwdist=bwdistgeodesic(kaki_th_edge,col(1),row(1),'quasi-euclidean');
bwdistmax=max(bwdist);
tatemax=distmax*pix;
%%重心の検出
cc2=regionprops(kaki_th,'Centroid');
centroids=cat(1,cc2.Centroid);
figure(11)
imshow(kaki_th);
hold on
plot(centroids(:,1),centroids(:,2),'r*');
hold off
%%画像を重ねる
C=imfuse(kaki_th,kaki_img);
figure(12)
imshow(C);
title('kaki_th(元画像との比較）');
pixについては、以下のプログラムと写真の一マスが10mmのため2マスの間隔をプロットすることで算出しています。
このpixをベースに、対象物の長手方向と短手方向を写真でプロットして、最長距離を算出します。
pixを用いることで、実際の対象物の長さを算出しているのですが、それぞれの大小関係を把握できれば良いため、pixを用いずに算出できたらなと考えています。
%% 画像入力(寸法計算用)
sunpo=imread('base_box_scale.jpg');
figure(1)
imshow(sunpo)
[x,y,P]=impixel(sunpo); %クリックしたpixelの座標
%注) クリックsuru画像の点は20mmと定める
[x,y]; %クリックした距離の間にあるpixelの数
Dis1=(((x(2)-x(1))^2)+((y(2)-y(1))^2))^(1/2); %1回目と2回目
Dis2=(((x(4)-x(3))^2)+((y(4)-y(3))^2))^(1/2); %3回目と4回目
Dis3=(((x(6)-x(5))^2)+((y(6)-y(5))^2))^(1/2); %5回目と6回目
Dis4=(((x(8)-x(7))^2)+((y(8)-y(7))^2))^(1/2); %7回目と8回目
Dis5=(((x(10)-x(9))^2)+((y(10)-y(9))^2))^(1/2); %9回目と10回目も距離
Disav=(Dis1+Dis2+Dis3+Dis4+Dis5)/5; %Dis1～5の平均値
pix=20/(Disav); %Disavの距離を20mmと最初に設定し,1pixelあたりの距離[mm]を算出
Nagae Ryoyahttps://jp.mathworks.com/matlabcentral/profile/authors/7977636-nagae-ryoyatag:jp.mathworks.com,2005:Question/4862342019-10-19T03:08:34Z2019-10-19T04:43:01Zhow can i generate the random numbers for specific probabilitesHello everyone.
I need to choose a random number for each probablitiy. The code is in the attachment. The code is perfect, i just need a random number for each probability.
Its really confusing for me. So if somebody can help me to solve ths problem, i will be very thankfull..
Thanks
waqas muhammadhttps://jp.mathworks.com/matlabcentral/profile/authors/10242532-waqas-muhammadtag:jp.mathworks.com,2005:Question/700182013-04-05T15:44:52Z2019-10-19T04:37:00ZHow to write cell array into a csv fileHello Everyone, I have a cell array C where the first row is string and the remaining rows contain numbers. How do I write the variable C into a CSV file?
For example,
c = {'abc' 'def' 'ghk';[23],[24],[67];[87],[13],[999];[656],[6767],[546]};
ThanksJalaj Bidwaihttps://jp.mathworks.com/matlabcentral/profile/authors/3071973-jalaj-bidwaitag:jp.mathworks.com,2005:Question/4577522019-04-22T07:07:44Z2019-10-19T04:36:41ZFitting Monod Equation with ODE45 to data using lsqcurvefit functionHello!
I am fitting Monod equation to a data containing substrate (s), biomass (x), and ethanol (p) concentration against time. The objective is to get the parameters: 1) umax, 2) ks, 3) Yxs, and 4)Yps that will best represent the data. The differential equations are:
Here is my initial code using assumed values of the four parameters:
umax = 0.5;
ks = 6.5;
Yxs = 0.2;
Yps = 1.2;
%a(1) = x
%a(2) = s
%a(3) = p
f = @(t,a) [umax*a(1)*a(2)/(ks + a(2)); -(1/Yxs)*umax*a(1)*a(2)/(ks + a(2)); (1/Yps)*umax*a(1)*a(2)/(ks + a(2))];
xt0 = [0.0904,9.0115,0.0151];
[tspan,a] = ode45(f,[0 25],xt0);
figure
plot(tspan,a(:,1),tspan,a(:,2),tspan,a(:,3))
Here is the code for trying to fit it into the actual data (script file):
function pos = paramfun1(x,tspan)
umax = x(1);
ks = x(2);
Yxs = x(3);
Yps = x(4);
xt0 = x(5:7);
f = @(t,a) [umax*a(1)*a(2)/(ks + a(2)); -(1/Yxs)*umax*a(1)*a(2)/(ks + a(2)); (1/Yps)*umax*a(1)*a(2)/(ks + a(2))];
[~,pos] = ode45(f,tspan,xt0);
Here is my call function (in the command window):
xt0 = zeros(1,7);
xt0(1) = umax;
xt0(2) = ks;
xt0(3) = Yxs;
xt0(4) = Yps;
data =[0 3 5 8 9.5 11.5 14 16 18 20 25 27, 0.0904 0.1503 0.2407 0.3864 0.5201 0.6667 0.8159 0.9979 1.0673 1.1224 1.1512 1.2093; 0 3 5 8 9.5 11.5 14 16 18 20 25 27, 9.0115 8.8088 7.9229 7.2668 5.3347 4.911 3.5354 1.4041 0 0 0 0; 0 3 5 8 9.5 11.5 14 16 18 20 25 27, 0.0151 0.0328 0.0621 0.1259 0.2949 0.3715 0.4199 0.522 0.5345 0.6081 0.07662 0.7869];
%time =[0 3 5 8 9.5 11.5 14 16 18 20 25 27];
[pbest,exitflag,output] = lsqcurvefit(@paramfun,xt0,tspan,data);
fprintf('New parameters: %f, %f, %f, %f',pbest(1:4));
The error is function value not equal to YDATA. Btw, this code was based from an example in MATLAB. (https://www.mathworks.com/help/optim/ug/fit-differential-equation-ode.html)
My data is:
time = [0 3 5 8 9.5 11.5 14 16 18 20 25 27]
x = 0.0904 0.1503 0.2407 0.3864 0.5201 0.6667 0.8159 0.9979 1.0673 1.1224 1.1512 1.2093
s = 9.0115 8.8088 7.9229 7.2668 5.3347 4.911 3.5354 1.4041 0 0 0 0
p = 0.0151 0.0328 0.0621 0.1259 0.2949 0.3715 0.4199 0.522 0.5345 0.6081 0.07662 0.7869
Please help! I do not know how to input my data into the lsqcurvefit function.
Thanks in advance!StarSign1997https://jp.mathworks.com/matlabcentral/profile/authors/15259909-starsign1997tag:jp.mathworks.com,2005:Question/4855252019-10-15T19:21:18Z2019-10-19T04:32:46Zread text file and put its values in a vectori want to read a vector its values saved in a text file and put those values in vector on matlabMohamed Aymanhttps://jp.mathworks.com/matlabcentral/profile/authors/16564244-mohamed-aymantag:jp.mathworks.com,2005:Question/4858132019-10-17T06:12:17Z2019-10-19T04:32:20Z2D-Lookup table のエクセルからのデータのインポート方法について2D-lookup table を使って制御値のマップを作成したいのですが、エクセルで作成した添付画像のようにするにはどうすれば良いでしょうか。
エクセルのデータは手動入力できないほどの膨大のデータなので簡単にインポートできる方法はありますでしょうか。
また、このデータはそれぞれ行の長さが違うのですがその場合でも作成可能でしょうか。
バージョンは2016bになります
shttps://jp.mathworks.com/matlabcentral/profile/authors/13156270-stag:jp.mathworks.com,2005:Question/4862382019-10-19T04:14:18Z2019-10-19T04:26:21ZInterpolation of a set of x , y data to a curveI want to interpolate a set of data which are x , y points of a hystersis plot.
please help me how can I find best interpolation in such case and after that how can I find it's slope to find knee point?
thanks!saeid haghighipourhttps://jp.mathworks.com/matlabcentral/profile/authors/12924870-saeid-haghighipourtag:jp.mathworks.com,2005:Question/4862232019-10-18T23:28:01Z2019-10-19T04:25:10Zplease i need guide this questionAdvanced Reaction Kinetics for Energy
Coursework 2019/20 – HAND IN DEADLINE – 02/11/2019 FT (09/11/2019 PT)
Problem
Write a MATLAB script(s) to model the transient heat and mass transfer, and combustion reaction within a particle of biomass char using the finite differences approach.
Using this model, vary some parameters to see how they affect the progression of combustion reaction and heat and mass transfer. Write a short report (5 pages should be enough) detailing your research hypothesis and findings. You may use literature sources to discuss your results further.
Assumptions
Assume a one-dimensional spherical biomass char particle under transient (unsteady state) heat and mass transfer with reaction.
Assume no radiation heat transfer, only conduction and convection.
Assume the particle starts off at 25 °C with air inside any pore space and combusts in air that has been preheated to the reaction temperature.
Assume that biomass char is 100% pure carbon and only the gas-solid char oxidation reaction occurs.
Assume that specific heat capacity and thermal conductivity of the biomass char don’t vary with temperature or orientation of the char particle.
Assume porosity, surface area, and density of the char particle don’t vary with conversion.
Conversion can be determined via the following equation:
Apply the following equation for the kinetic rate equation:
One dimensional heat continuity equation for a sphere:
One dimensional mass continuity equation for a sphere:
Apply the following boundary conditions:
r = 0, t ≥ 0
r = rend, t ≥ 0
r = 0, t ≥ 0
r = rend, t ≥ 0
Use the Chapman Enskog coefficient found on page 27 of Bird, Stuart and Lightfoot – Transport Phenomena (see uploaded version on blackboard), eqn(1.4-16) in the 2nd edition, to calculate the thermal conductivity, specific heat capacity, dynamic viscosity, and density of the mixed gases.
Use the following equations for the dimensionless numbers:
Reynolds, Re
Prandtl, Pr
Sherwood, Sh
Nusselt, Nu
Schmidt, Sc
You may use the following values as initial values, as well as any data from the NIST chemistry webbook thermophysical properties https://webbook.nist.gov/chemistry/fluid/:
Parameter
Value
Unit
Specific heat capacity of biomass char, Cp
1.5
kJ/kg·K
Thermal conductivity of biomass char, k
0.2
W/m·K
Density of particle, ρp
650
kg/m3
Particle radius, r
5×10-4
m
Initial particle temperature, T0
20
°C
Reaction/bulk gas temperature, Tb
800
°C
Particle porosity, εp
40
%
Molar particle density, ρp-molar
54,167
mol/m3
Surface area of biomass char, S
0.1
m2/g
Reaction pressure, P
1
Bar(a)
Partial pressure of O2 in initial combustion air, PO2
0.21
Bar(a)
Partial pressure of N2 in initial combustion air, PN2
0.79
Bar(a)
Partial pressure of CO2 in initial combustion air, PCO2
0
Bar(a)
Superficial gas velocity, v
0.7
m/s
Initial particle conversion, X
0
%
Ideal gas constant, R
8.314
J/K·mol
Relative molecular mass of O2, RMMO2
16
g/mol
Relative molecular mass of N2, RMMN2
14
g/mol
Relative molecular mass of CO2, RMMCO2
44
g/mol
Relative molecular mass of C, RMMC
12
g/mol
Final time for ODE, t
150
s
Activation energy, EA
120.4
kJ/mol
Pre-exponential factor, A
3.07 × 1010
s-1
Reaction enthalpy, ΔHᶱ
393.52
kJ/mol
Shell volume, Vshell
4/3π(ri+1 - ri)3
m3
Nomenclature of other undefined terms
Mass transfer coefficient
kg
m/s
Heat transfer coefficient
h
W/m2·K
Rate constant
k”
m/s
Concentration of gas y, Py / RT
Cy
mol/m3
Subscripts
Gas, g
Particle, p
Bulk gas, B
Position within particle, i
Each gas (CO2, N2, O2), y
Outer most part of particle, end
Effective, eff
Outputs to be submitted
A short report covering the following items:
Abstract (max 150 words)
Description of model (~1-2 pages)
Results and discussion of using the model (~1-2 pages)
Any references you have used (no page limit)
The report should use the following formatting style guidelines:
2 cm margins on all sides
Main text and captions - Arial font, size 11, black, justified text
Headings – Arial font, size 12, black, bold, centre aligned
Sub-headings – Arial font, size 11, black, bold, left aligned
Student ID number and title of report in header
All figures, tables, equations, chemical symbols should be formatted as detailed in the academic writing presentation shown in induction week
All required MATLAB codes with a README.txt document, so that I can run your model and check it works. The MATLAB codes should be set up so that I only need to press ‘Run’ once. The README.txt file should inform me which code I need to open, and press ‘Run’ within.
The outputs of the model should be to plot four 3D mesh plots of:
Time vs particle radius vs temperature
Time vs particle radius vs conversion
Time vs particle radius vs CO2 partial pressure
Time vs particle radius vs O2 partial pressure
The marking rubric for this coursework is shown below.
Marking rubric
Fail (<49%)
Pass (50-64%)
Good (65-79%)
Excellent (>80%)
MATLAB scripts
[60% weighting]
Minimal programming has been undertaken, or multiple mistakes are apparent such that not even simple parts of the scripts work on their own.
No README file submitted.
No comments provided in the scripts.
Scripts may not work in their entirety to produce the correct final output, but the only errors within their scripts must be around the finite difference’s implementation or boundary conditions implementation. The remaining proportion of the scripts must be fully functional.
No README file submitted.
Minimal comments are provided in the scripts and it might be difficult to follow exactly what is being calculated/performed at each point.
Scripts work to solve the problem and simulate the char combustion.
Minimal errors (e.g. brackets in the wrong place) may be apparent but these errors must not affect the operation of the scripts.
README file submitted and understandable.
Variable naming is understandable and detailed comments are provided throughout the scripts.
Scripts work to solve the problem and simulate the char combustion.
The four requested 3D mesh plots are produced automatically when running the scripts. These plots must be plotted by the script, not opened from a saved file.
No errors are apparent in the scripts.
README file submitted and understandable.
Variable naming is understandable and detailed comments are provided throughout the scripts.
Additional scripts/plots/defined edits to the scripts are presented, which show how the student has applied their research hypothesis and explored the effect of changing variables.
Report
[30% weighting]
No report submitted or report missing two or more of the sections (abstract, model description, results and discussion, references)
Abstract (max 150 words)
Description of model (~1-2 pages)
Results and discussion of using the model (~1-2 pages)
Any references you have used (no page limit)
Abstract comments more on what has been done rather than what results have been achieved.
The description of the model is vague and not clear to understand. Little focus has been paid to explaining the key concepts of how the model works.
The results are mentioned and repeated in a table or figure.
No discussion of the results with respect to the literature is performed.
Research hypothesis may be present, but few results or discussion are provided.
References may be present but are from poor sources (Wikipedia, engineering tool box, or other such websites).
No attention to formatting of references has been given.
Abstract succinctly describes the work and the key findings of the work.
The description of the model is clear and easy to understand. Detailed explanations of the key concepts and how the model works are given.
The results are reported and not repeated in the text and tables/figures, and form part of the discussion.
A discussion is provided which considers how the results relate to literature data. Literature data must be cited appropriately and consistently.
Evidence of a research hypothesis and its implementation is given. The results of the testing/simulations of this research hypothesis are given and briefly discussed.
References present and are from academic or industrial sources (peer reviewed being favoured).
References are consistently formatted.
Abstract succinctly describes the work and the key findings of the work.
The description of the model is clear and easy to understand. Detailed explanations of the key concepts and how the model works are given.
The results are reported and not repeated in the text and tables/figures, and form part of the discussion.
A detailed discussion is provided which considers critically how the results relate to literature data. Literature data must be cited appropriately and consistently.
A clearly stated and scientific research hypothesis and its implementation is given. The results of the testing/simulations of this research hypothesis are given and discussed in detail.
References present and are from academic or industrial sources (peer reviewed being favoured).
References are consistently formatted.
Communication and style
[10% weighting]
Report does not follow style guidelines at all.
The scripts are not formatted well to enable easy readability.
The style of the figures, tables, equations, and MATLAB plots are non-existent or do not adhere to the academic writing guidelines.
Report partially follows style guidelines.
The scripts are not formatted well to enable easy readability.
The style of the figures, tables, equations, and MATLAB plots are of a low quality and do not adhere to the academic writing guidelines.
Report fully follows style guidelines.
The scripts are mostly formatted well to enable easy readability.
The style of the figures, tables, equations, and MATLAB plots are of mostly to a high quality and easily readable and adhere to the academic writing guidelines.
Report fully follows style guidelines.
The scripts are formatted well to enable easy readability.
The style of the figures, tables, equations, and MATLAB plots are of high quality and easily readable and adhere to the academic writing guidelines.
function_g
Adamu Joshuahttps://jp.mathworks.com/matlabcentral/profile/authors/16614715-adamu-joshuatag:jp.mathworks.com,2005:Question/4861892019-10-18T17:07:51Z2019-10-19T04:21:54Zoverlay mask on sequence of mri images to mark out tumor ROII created a mask based on one frame to mark out my ROI region.
segment_mask = poly2mask(xi, yi, 256, 256);
Is there a way I can overlay this mask onto my sequence of frames stored in a 3d array(256 x 256 x #of frames)?Raheema Al Karim Damanihttps://jp.mathworks.com/matlabcentral/profile/authors/15751635-raheema-al-karim-damanitag:jp.mathworks.com,2005:Question/4862092019-10-18T20:04:07Z2019-10-19T04:18:54Zif condition problem and positive conditionDear Matlab experts,
I added "if condition" in the Matlab coding.
I defined m1 = n1-ee1, and I used "if condition" because I would like to get only positive value for m1.
However, I could not get any result.
if n1 <= ee1
m1 =0;
else if n1 > ee1
m1 = n1 - ee1;
My full coding is below. Please let me know how to fix it.
Thank you very much in advance.
Sincerely yours,
J1
t = 0:.0001: 5;
z = 1819;
e1 = -42;
e2 = -7;
e3= -20;
e4= -29;
e5 = -32;
e6 = -112;
e7 = -70;
e8 = -9;
e9 = -48;
e10 = -14;
e11 = -2;
e12 = -22;
e13= -42;
e14= -15;
e15 = -26;
e16 = -58;
e17 = -24;
e18 = -73;
e19 = -102;
e20 = -78;
e21 = -600;
e22 = -11;
e23= -65;
e24= -285;
e25 = -32;
p = exp(-t.*e1) + exp(-t.*e2) + exp(-t.*e3) + exp(-t.*e4) + exp(-t.*e5) + exp(-t.*e6) + exp(-t.*e7) + exp(-t.*e8) + exp(-t.*e9) + exp(-t.*e10) + exp(-t.*e11) + exp(-t.*e12) + exp(-t.*e13) + exp(-t.*e14) + exp(-t.*e15) + exp(-t.*e16) + exp(-t.*e17) + exp(-t.*e18) + exp(-t.*e19) + exp(-t.*e20) + exp(-t.*e21) + exp(-t.*e22) + exp(-t.*e23) + exp(-t.*e24) + exp(-t.*e25) ;
b1 = (exp(-t.*e1))./p;
b2 = (exp(-t.*e2))./p;
b3 = (exp(-t.*e3))./p;
b4 = (exp(-t.*e4))./p;
b5 = (exp(-t.*e5))./p;
b6 = (exp(-t.*e6))./p;
b7 = (exp(-t.*e7))./p;
b8 = (exp(-t.*e8))./p;
b9 = (exp(-t.*e9))./p;
b10 = (exp(-t.*e10))./p;
b11 = (exp(-t.*e11))./p;
b12 = (exp(-t.*e12))./p;
b13 = (exp(-t.*e13))./p;
b14 = (exp(-t.*e14))./p;
b15 = (exp(-t.*e15))./p;
b16 = (exp(-t.*e16))./p;
b17 = (exp(-t.*e17))./p;
b18 = (exp(-t.*e18))./p;
b19 = (exp(-t.*e19))./p;
b20 = (exp(-t.*e20))./p;
b21 = (exp(-t.*e21))./p;
b22 = (exp(-t.*e22))./p;
b23 = (exp(-t.*e23))./p;
b24 = (exp(-t.*e24))./p;
b25 = (exp(-t.*e25))./p;
n1 = z*b1;
n2 = z*b2;
n3 = z*b3;
n4 = z*b4;
n5 = z*b5;
n6 = z*b6;
n7 = z*b7;
n8 = z*b8;
n9 = z*b9;
n10 = z*b10;
n11 = z*b11;
n12 = z*b12;
n13 = z*b13;
n14 = z*b14;
n15 = z*b15;
n16 = z*b16;
n17 = z*b17;
n18 = z*b18;
n19 = z*b19;
n20 = z*b20;
n21 = z*b21;
n22 = z*b22;
n23 = z*b23;
n24 = z*b24;
n25 = z*b25;
ee1 = 42;
ee2 = 7;
ee3 = 20;
ee4 = 29;
ee5 = 32;
ee6 = 112;
ee7 = 70;
ee8 = 9;
ee9 = 48;
ee10 = 14;
ee11 = 2;
ee12 = 22;
ee13 = 42;
ee14 = 15;
ee15 = 26;
ee16 = 58;
ee17 = 24;
ee18 = 73;
ee19 = 102;
ee20 = 78;
ee21 = 600;
ee22 = 11;
ee23 = 65;
ee24 = 285;
ee25 = 32;
m1 = n1 - ee1;
m2 = n2 - ee2;
m3 = n3 - ee3;
m4 = n4 - ee4;
m5 = n5 - ee5;
m6 = n6 - ee6;
m7 = n7 - ee7;
m8 = n8 - ee8;
m9 = n9 - ee9;
m10 = n10 - ee10;
m11 = n11 - ee11;
m12 = n12 - ee12;
m13 = n13 - ee13;
m14 = n14 - ee14;
m15 = n15 - ee15;
m16 = n16 - ee16;
m17 = n17 - ee17;
m18 = n18 - ee18;
m19 = n19 - ee19;
m20 = n20 - ee20;
m21 = n21 - ee21;
m22 = n22 - ee22;
m23 = n23 - ee23;
m24 = n24 - ee24;
m25 = n25 - ee25;
if n1 <= ee1
m1 =0;
else if n1 > ee1
m1 = n1 - ee1;
y = m1.*m1 + m2.*m2 + m3.*m3 + m4.*m4 + m5.*m5 + m6.*m6 + m7.*m7 + m8.*m8+ m9.*m9 + m10.*m10 +m11.*m11 + m12.*m12 + m13.*m13 + m14.*m14 + m15.*m15 + m16.*m16 + m17.*m17 + m18.*m18+ m19.*m19 + m20.*m20+ m21.*m21 + m22.*m22 + m23.*m23 + m24.*m24 + m25.*m25;
plot(t, sqrt(y))
[ymin, yi] = min(y);
tmin = t(yi)
ymin =y(yi)Redwoodhttps://jp.mathworks.com/matlabcentral/profile/authors/4232596-redwoodtag:jp.mathworks.com,2005:Question/4862392019-10-19T04:16:34Z2019-10-19T04:16:34ZError using - Matrix dimensions must agree. Error in tvf_emd (line 136) temp_x = temp_x-y(ind_remov_pad); please I will be grateful for any help for this error:
Error using -
Matrix dimensions must agree.
Error in tvf_emd (line 136)
temp_x = temp_x-y(ind_remov_pad);
the code is below:
if flag_stopiter
imf(nimf,:)=y(ind_remov_pad);
temp_x = temp_x-y(ind_remov_pad);
break;
endYussif Moro Awelisahhttps://jp.mathworks.com/matlabcentral/profile/authors/13640172-yussif-moro-awelisahtag:jp.mathworks.com,2005:Question/4862372019-10-19T04:08:35Z2019-10-19T04:08:35ZWhy do I get non integer results from MILP problem ?I have a script for diet linear programming problem. I am trying to compare results of linearprog or(intlinprog) with results of cplexlp(or cplexmilp) functions provided by toolbox CPLEX for matlab by IBM
here is the script
%% Defining Variables
clear;clc
Pnames = ["BEEF";
"CHK";
"FISH";
"HAM";
"MCH";
"MTL";
"SPG";
"TUR" ];
Packs = optimvar('Packs',Pnames,'Type','integer');
Packs.LowerBound = 2*ones(length(Pnames),1);
Packs.UpperBound = 10*ones(length(Pnames),1);
%% Setting the problem data
CostPerPack = [3.19;2.59;2.29;2.89;1.89;1.99;1.99;2.49];
VitA = [60;8;8;40;15;70;25;60];
VitC = [20;0;10;40;35;30;50;20];
VitB1 = [10;20;15;35;15;15;25;15];
VitB2 = [15;20;10;10;15;15;15;10];
NA = [938;2180;945;278;1182;896;1329;1397];
CAL = [295;770;440;430;315;400;370;450];
% Amount Per package table
TAMT = table(VitA,VitC,VitB1,VitB2,NA,CAL,...
'VariableNames',{'A','C','B1','B2','NA','CAL'},...
'RowNames',Pnames);
%% Objective
TotCost = sum(CostPerPack .* Packs); % Objective
obj = TotCost;
%% Constraints
prob = optimproblem('Objective',obj,'ObjectiveSense','min');
prob.Constraints.c1 = sum(VitA.*Packs) >= 700;
prob.Constraints.c1a = sum(VitA.*Packs) <= 20000;
prob.Constraints.c2 = sum(VitC.*Packs) >= 700;
prob.Constraints.c2a = sum(VitC.*Packs) <= 20000;
prob.Constraints.c3 = sum(VitB1.*Packs) >= 700;
prob.Constraints.c3a = sum(VitB1.*Packs) <= 20000;
prob.Constraints.c4 = sum(VitB2.*Packs) >= 700;
prob.Constraints.c4a = sum(VitB2.*Packs) <= 20000;
prob.Constraints.c5 = sum(NA.*Packs) >= 0;
prob.Constraints.c5a = sum(NA.*Packs) <= 40000;
prob.Constraints.c5 = sum(CAL.*Packs) >= 16000;
prob.Constraints.c5a = sum(CAL.*Packs) <= 24000;
%% Putting the problem together and solving
problem = prob2struct(prob);
% LP
% [sol,fval,exitflag,output1] = linprog(problem);
% [sol2,fval2,exitflag2,output2] = cplexlp(problem);
% MILP problem
[sol,fval,exitflag,output1] = intlinprog(problem);
[sol2,fval2,exitflag2,output2] =cplexmilp(problem);
%% Display
disp('Linear Prog function results')
if (~isempty(sol) )
T1 = table(sol,sol.*VitA,sol.*VitC,sol.*VitB1,sol.*VitB2,sol.*NA,sol.*CAL,sol.*CostPerPack,...
'VariableNames',{'NuofPacks','PerVitA','PerVitC','PerVitB1','PerVitB2','NA','CAL','Cost'},...
'RowNames',Pnames);
sumrow = array2table(sum(T1.Variables),...
'VariableNames',...
{'NuofPacks','PerVitA','PerVitC','PerVitB1','PerVitB2','NA','CAL','Cost'},...
'RowNames',"Sum");
T1 = [T1;sumrow];
disp(T1)
else
disp(['No feasible Solution with exit flag = ' ,num2str(exitflag)])
end
%% Display Cplex
disp('Cplex function results')
if (~isempty(sol2) )
T2 = table(sol2,sol2.*VitA,sol2.*VitC,sol2.*VitB1,sol2.*VitB2,sol2.*NA,sol2.*CAL,sol2.*CostPerPack,...
'VariableNames',{'NuofPacks','PerVitA','PerVitC','PerVitB1','PerVitB2','NA','CAL','Cost'},...
'RowNames',Pnames);
sumrow2 = array2table(sum(T2.Variables),...
'VariableNames',...
{'NuofPacks','PerVitA','PerVitC','PerVitB1','PerVitB2','NA','CAL','Cost'},...
'RowNames',"Sum");
T2 = [T2;sumrow2];
disp(T2)
else
disp(['No feasible Solution with exit flag = ' ,num2str(exitflag2)])
end
and here is the results
The reults for this MILP from intlinprog seems good but from cplexmilp I get non-ineger value for SPG package.
Can anyone help me to know the problem here ?
Thanks in advance omar khaterhttps://jp.mathworks.com/matlabcentral/profile/authors/8700367-omar-khatertag:jp.mathworks.com,2005:Question/4862362019-10-19T04:06:26Z2019-10-19T04:06:26ZCreating a sinusoidal graphHello,
I have a homework to do using matlab, and it is asking me to create three lines:
It says to plot exactly two cycles of the lowest frequency, and this is what I did:
I randomly typed 100 numbers for the values of t, but and set the x axis length to 2 so that the red line with the lowest frequency would have exactly two cycles.
However, when I change the number of values for t, the number of waves change. The question doesn't say anything about the number of values for t. Maybe I am interpreting the question incorrectly. Can someone please help me understand this question?
Thank you.Hami the Penguinhttps://jp.mathworks.com/matlabcentral/profile/authors/16143052-hami-the-penguintag:jp.mathworks.com,2005:Question/4861912019-10-18T17:27:05Z2019-10-19T04:03:11Zi have removed frequency from (3-200)HZ from FFT signal.Now i want to remove noise from last figure which is in time domain so that i can transmit signal.Thanks in advance.clc,close all,clear all
codn=70;
% fc=6e+3;
fs=3600;
bode=10;
code=round(rand(1,codn));
code_len=round(1/bode/(1/fs))
for ii=1:codn
x((ii-1)*code_len+1:code_len*ii)=code(ii);
end
x2 = x-(1/2) % get rid of most of the dc peak
% set up time and frequency arrays
N = length(x);
delt = 1/fs;
delf = fs/N
tvec = (1:N)*delt
fvec = (-N/2:N/2-1)*delf ; % shifted frequency array
figure(1)
plot(tvec,x2(1,:)+0.5)
title('orignal baseband')
xlabel('time');
ylabel('amplitude')
ylim([-1 1.5]);
y = fftshift(fft(x2)/N);
z=abs(y);
figure(2)
plot(fvec,abs(y))
title('FFT')
xlabel('frequency')
ylabel('amplitude')
figure(3)
z=y;
z(abs(fvec)>=3 & abs(fvec)<=200)=0
plot(fvec,abs(z))
xlabel('frequency removed from 3 to 200 HZ');
ylabel('amplitude')
figure(4)
zf=fftshift(z)*N;
zifft=ifft(zf)+0.5
plot(tvec,abs(zifft))
ylim([-1 1.5])
title('recovered signal')
xlabel('time');
ylabel('amplitude')
imran khanhttps://jp.mathworks.com/matlabcentral/profile/authors/16304652-imran-khantag:jp.mathworks.com,2005:Question/4862282019-10-19T01:22:31Z2019-10-19T03:55:30ZImplementing high precision, millisecond-timescale timerI'm trying to implement a high-precision, millisecond-timescale timer in matlab. Every T seconds, I want to query a camera linked to matlab, and if there is an image in the memory, I want to pull it out. The actual connection to the camera is straightforward - but a problem arises because images are coming in every ~60ms, and need to all be pulled off before another image enters the camera buffer. This essentially means that I need to be checking the camera buffer at least every ~30ms, and ideally every ~5ms.
While MATLAB's built in timer function ostensibly allows millisecond timing, it suffers from poor precision. While in >95% of executions the built in MATLAB timer will indeed pause for ~5ms between runs, in ~5% of cases it hovers around ~30ms, and in ~1% of cases it takes >100ms between executions, which unacceptably kills the performance. I should clarify in MATLAB's defense that simultaneously there are two other timers running (both with 1 s periods), as well as a number of figure windows open, so even though my machine is beefy (16-core, 64GB RAM), there is certainly a lot to be doing all at once. I have tried using timers based on .NET timers (System.Timers.Timer(period)) as well as with the Java sleep function (java.lang.Thread.sleep(period)), both of which should theoretically be more precise, and while both are better than the MATLAB timer (at the cost of being more unwieldy), none are able to consistently achieve <60ms execution delay across thousands of iterations.
Maybe I'm asking for something which is not implementable - but I hope that there is some way to implement a high-precision timer in MATLAB which will continue executing at a ms time-scale even when there are other figures/timers/commands being executed semi-simultaneously. I should maybe clarify that when running just a timer with no other timers/figures open I am able to consistently achieve <60ms execution (and really, consistent <10ms execution for a 5ms timer period). This is possible even when all those timers/figures are open in a different instance of MATLAB, so it seems the problem is to somehow separate the timer from the rest of MATLAB. Any advice or guidance would be appreciated in this regard.Adam Shawhttps://jp.mathworks.com/matlabcentral/profile/authors/14100079-adam-shawtag:jp.mathworks.com,2005:Question/4862302019-10-19T01:41:06Z2019-10-19T03:55:15ZDesigning a Notch FilterHello,
I'd like to design a notch filter with Fs=22050Hz, frequency=60Hz sinusoidal signal. Can someone please tell me what parameters to pass inside the notch filter function?
Also, I have a voice signal saved as .wav file in my computer, and I want to mix it with the above 60Hz sine signal. Can someone help me with both my queries? I've been trying a few ways, but couldn't find the result.
ThanksSri Srujan Gollapudihttps://jp.mathworks.com/matlabcentral/profile/authors/16049586-sri-srujan-gollapuditag:jp.mathworks.com,2005:Question/4858522019-10-17T09:33:14Z2019-10-19T03:43:39ZUsing surrogate optimization to reproduce analytical resultsI am trying to reproduce results from the following paper:
https://www.researchgate.net/publication/261186477_Optimal_design_of_a_novel_tuned_mass-damper-inerter_TMDI_passive_vibration_control_configuration_for_stochastically_support-excited_structural_systems
In the paper above, the system is a SDOF with an attached tuned mass damper inerter, known as a TMDI. The inerter is a passive device that essentially adds virtual mass to the system.
The paper derived analytical results for optimal values of nu (ratio of natural frequency of the TMDI to the primary structure) and zeta2 (damping ratio of the TMDI), which are shown in equations 15 and 16, respectively. These were found by choosing the cost function to be the variance of the primary structure displacement (equation 8). Moreover, the input into the system is ideal white noise with zero mean and variance of one.
What I am trying to do is reproduce these optimal values (or get very close to them) numerically using surrogate optimization. Unfortunately, when I attempt to do this, I can't seem to reproduce the results, in particular, for mu=0.01 and bbeta=0.2. In fact, the optimization leads to a smaller objective function, which does not make sense, since the analytical results should produce the smallest objective function. I can't seem to pinpoint why this discrepancy occurs.
My code is broken into 3 parts:
objfunc_tmdi calculates the cost function.
tmdi is the ODE for the 2DOF system.
surrogateoptimization_tmdi creates white noise (and saves in .mat file for reproducibility) and runs surrogate optimization using the above two files.
% set parameters for system
mu = 0.01;
bbeta = 0.2;
% define time domain
tstart = 0;
stepsize = 1e-3;
tfinal = 10;
% % generate white noise
% mu_wn = 0;
% sigma_wn = 1;
% twhitenoise = tstart:stepsize:tfinal;
% whitenoise = sigma_wn*randn(length(twhitenoise),1)+mu_wn;
% saved white noise for reproducibility
load('whitenoiseinput.mat')
% use gridded interpolant to speed up ode45 when inputting white noise
data_set = griddedInterpolant(twhitenoise,whitenoise);
objfunctmdi = @(para)objfunc_tmdi(para,mu,bbeta,data_set);
lb_tmdi = [0;0];
ub_tmdi = [4;2];
options = optimoptions('surrogateopt','useparallel',true);
[paratmdi,fvaltmdi,exitflagtmdi,trialstmdi] = ...
surrogateopt(objfunctmdi,lb_tmdi,ub_tmdi,options);
% analytical results for nu and zeta2
nu = (1/(1+bbeta+mu))*sqrt((bbeta+mu)*(bbeta*(mu-1)+...
(2-mu)*(1+mu)))/(sqrt(2*mu*(1+mu)));
zeta2 = (bbeta+mu)*sqrt(bbeta*(3-mu)+(4-mu)*(1+mu))...
/(2*sqrt(2*mu*(1+bbeta+mu)*(bbeta*(1-mu)+(2-mu)*(1+mu))));
function cost = objfunc_tmdi(para,mu,bbeta,data_set)
tstart = 0;
tfinal = 10;
tspan = [tstart tfinal];
options = odeset('RelTol',1e-6, 'AbsTol',1e-6);
x0 = zeros(4,1);
[~,x] = ode45(@(t,x) tmdi(t,x,mu,bbeta,para,data_set), ...
tspan,x0,options);
% define cost function to be variance of x_1
cost = var(x(:,1));
end
function dz = tmdi(t,z,mu,bbeta,para,data_set)
nu = para(1);
zeta2 = para(2);
m1 = 18000;
m2 = m1*mu ;
b = bbeta*m1;
% define k1 where omega1=2*pi (natural frequency of primary structure)
k1 = (2*pi)^2*m1;
k2 = nu^2*m2*(k1/m1);
c2 = 2*zeta2*m2*sqrt(k2/m2);
M = [m1 0;
0 m2+b];
K = [k1+k2 -k2;
-k2 k2];
C = [c2 -c2;
-c2 c2];
A = [zeros(2,2) eye(2,2) ; -M\K -M\C];
E = -[zeros(2,2) ; M\eye(2,2)];
whitenoise = [m1*data_set(t) ; m2*data_set(t)];
dz = A*z + E*whitenoise;
end
I have a couple other questions as well:
Is the way I created white noise to adequately approximate ideal white noise? Is the number of samples I chose sufficient?
Is using the default value of 200 iterations enough? What are some tips on choosing the number of iterations?
Thanks for any help!
Shant Danielianhttps://jp.mathworks.com/matlabcentral/profile/authors/7422401-shant-danieliantag:jp.mathworks.com,2005:Question/4861232019-10-18T11:35:23Z2019-10-19T03:20:12ZCurve fitting by Genetic AlgorithmHi everybody, I have a very simple theoric problem but I don't know how to resolve it.
I just wanna do a curve fitting like this:
I want the red line to fit the red dashed one as much as possible in the [0.3 - 0.6] interval.
The red line is a 100x1 vector (x-axis) and 100x1 vector (y-axis).
The red dashed curve is given by this equation (much longer, cropped here):
function [ d2 ] = d2_current( alpha,beta,phi,N,V )
d2 = (4903985730770845.*N.*(((exp(alpha.*(phi - V.*(beta - 1))) + 1).*((alpha.^2.*beta.^2.*exp(alpha.*...
end
Where V is the dependent variable, the previous 100x1 vector (x-axis) corresponding to the [0.3 - 0.6] interval.
The equation depends on 4 independent parameters, each one of them may be included in these intervals:
beta; from to a 1
alpha; from 0 to 15
N; from 0 to 300
phi; from 0 to 3
I have to vary these parameters in order to obtain the best fitting, note that the parameters value must be the same for one single fitting.
The first thing I did was 4 different 'for' loops for each parameter and try to compare each single result with the red curve my means of the euclidean distance. (simplified code):
cont = 0;
for beta = 0:0.01:1
for alpha = 0:0.01:15
for N = 0:1:300
for phi = 0:0.01:3
distance_euclidean(cont,1) = norm(current_red_curve - current_red_dashed_curve);
cont = cont + 1;
end
end
end
end
minim_eucl = min(distance_euclidean);
The minimum euclidean distance would be the best fitting. For the graph example:
beta = 1;
alpha = 15;
N = 300;
phi = 0.45;
Everything is fine until this point, but there's a big problem: the computing time is just huge when the step in the 4 intervals decreases (needed because of the poor fitting).
Looking for better solutions I found the possible way to go: the genetic algorithm. I've been trying it on the Matlab optimization tool, but with no results.
Could somebody help me out?
Thank you very much for your help.
Regards,Juan Castillohttps://jp.mathworks.com/matlabcentral/profile/authors/12800191-juan-castillotag:jp.mathworks.com,2005:Question/3971142018-04-24T17:06:39Z2019-10-19T03:16:21ZWildcard or multiple conditions on switch/case?Hello,
Is there a way to deal with multiple conditions in switch/case? For example (this is just example):
* Meat could be chicken pork beef lamb
*
* Veggie could be beans peas corn
*
* Fruit could be apple pear blueberry
Looking for a way to then select for each possible combination. Is the easiest way just nested switch/case? Or is there something more elegant? Is there an easy way to use case wildcards (not great for this example)?
Thanks!
DougDouglas Andersonhttps://jp.mathworks.com/matlabcentral/profile/authors/4227986-douglas-andersontag:jp.mathworks.com,2005:Question/104792011-06-29T06:29:57Z2019-10-19T03:02:57ZContour plot along predefined surfaceHi,
I have 3D-data, with Z = f(x,y) in numerical format consistent with meshgrid.
I would like to make a contourplot of this surface along a given plane, _which is not parallel to the Z-axis_. I also want to get the X,Y-values of the intersection of this inclined plane and the surface Z in a matrix as output.
To get the idea, it's basically the same as the function
C = contourc(x,y,Z,v)
does, but contourc can apparently only handle elevations parallel with the Z-plane.
Of course, I can just rotate all the data so that its new Z-axis is perpendicular to the surface I wish to make the contour projections on (that's quite easy), but it seems too high computational effort.
Any help is appreciated.
Florishttps://jp.mathworks.com/matlabcentral/profile/authors/2004032-floristag:jp.mathworks.com,2005:Question/4861562019-10-18T14:33:34Z2019-10-19T03:01:07ZWhat function fits my data...?Hello, I am a bit unsure if this is the correct place to ask my question, but I'll try anyways:
I am doing laser triangulation, and I recorded the position of a laser point on the camera CMOS chip vs. a displacement.
I have a series of measurement points. y is the distance in mm from the camera (with an unknown offset), and x is the position of the laser point on the camera sensor (in pixels).
y=[0 5.97623500000000 11.9524700000000 17.9287050000000 23.9049400000000 29.8811750000000 35.8574100000000 41.8336450000000 47.8098800000000 53.7861150000000 59.7623500000000 65.7385850000000 71.7148200000000 77.6910550000000 83.6672900000000 89.6435250000000 95.6197600000000 101.595995000000 107.572230000000 113.548465000000 119.524700000000 125.500935000000 131.477170000000 137.453405000000 143.429640000000 149.405875000000 155.382110000000 161.358345000000 167.334580000000 173.310815000000 179.287050000000 185.263285000000 191.239520000000 197.215755000000 203.191990000000 209.168225000000 215.144460000000 221.120695000000 227.096930000000 233.073165000000 239.049400000000 245.025635000000 251.001870000000 256.978105000000 262.954340000000 268.930575000000 274.906810000000 280.883045000000 286.859280000000 292.835515000000 298.811750000000 304.787985000000 310.764220000000 316.740455000000 322.716690000000 328.692925000000 334.669160000000 340.645395000000 346.621630000000 352.597865000000 358.574100000000 364.550335000000 370.526570000000 376.502805000000 382.479040000000 388.455275000000 394.431510000000 400.407745000000 406.383980000000 412.360215000000 418.336450000000 424.312685000000 430.288920000000 436.265155000000 442.241390000000 448.217625000000 454.193860000000 460.170095000000 466.146330000000 472.122565000000 478.098800000000 484.075035000000 490.051270000000 496.027505000000 502.003740000000 507.979975000000 513.956210000000 519.932445000000 525.908680000000 531.884915000000 537.861150000000 543.837385000000 549.813620000000 555.789855000000 561.766090000000 567.742325000000 573.718560000000 579.694795000000 585.671030000000 591.647265000000 597.623500000000 603.599735000000 609.575970000000 615.552205000000 621.528440000000 627.504675000000 633.480910000000 639.457145000000 645.433380000000 651.409615000000 657.385850000000 663.362085000000 669.338320000000 675.314555000000 681.290790000000 687.267025000000 693.243260000000 699.219495000000 705.195730000000 711.171965000000 717.148200000000 723.124435000000 729.100670000000 735.076905000000 741.053140000000 747.029375000000 753.005610000000 758.981845000000 764.958080000000 770.934315000000 776.910550000000 782.886785000000 788.863020000000 794.839255000000 800.815490000000 806.791725000000 812.767960000000 818.744195000000 824.720430000000 830.696665000000 836.672900000000 842.649135000000 848.625370000000 854.601605000000 860.577840000000 866.554075000000 872.530310000000 878.506545000000 884.482780000000 890.459015000000 896.435250000000 902.411485000000 908.387720000000 914.363955000000 920.340190000000 926.316425000000 932.292660000000 938.268895000000 944.245130000000 950.221365000000 956.197600000000 962.173835000000 968.150070000000 974.126305000000 980.102540000000 986.078775000000 992.055010000000 998.031245000000 1004.00748000000 1009.98371500000 1015.95995000000 1021.93618500000 1027.91242000000 1033.88865500000 1039.86489000000 1045.84112500000 1051.81736000000 1057.79359500000 1063.76983000000 1069.74606500000 1075.72230000000 1081.69853500000 1087.67477000000 1093.65100500000 1099.62724000000 1105.60347500000 1111.57971000000 1117.55594500000 1123.53218000000 1129.50841500000 1135.48465000000 1141.46088500000 1147.43712000000 1153.41335500000 1159.38959000000 1165.36582500000 1171.34206000000 1177.31829500000 1183.29453000000 1189.27076500000 1195.24700000000];
x=[599.879427792916 669.403805496829 734.507982583454 793.957914338920 852.338173481085 906.812156862745 962.431716265797 1014.30095873281 1064.53915662651 1114.12381382738 1159.26240808824 1202.22931442080 1244.72289742343 1284.70789865872 1322.19885177453 1361.76739245884 1399.00976138829 1434.70044543430 1468.93040501997 1502.48020954598 1535.47037484885 1566.52059004302 1596.13613550816 1624.76059050064 1652.78768020970 1680.14513981358 1705.64774281806 1731.69461914745 1757.35486160397 1782.05118961788 1805.83234859675 1828.90676691729 1851.14908256881 1873.04921875000 1894.24110671937 1915.63857374392 1935.67927631579 1955.28571428571 1974.13945578231 1992.89205526770 2010.82620087336 2028.57193605684 2046.45855855856 2063.26118721461 2079.57953488372 2095.16353383459 2111.10516252390 2126.29990262902 2141.41878669276 2156.40556660040 2171.01210898083 2185.42959183673 2199.31714876033 2212.54214360042 2225.86933614331 2238.86552828175 2251.58817204301 2264.08487486398 2276.11378555799 2288.05016722408 2300.15919282511 2311.73356009070 2322.75834292290 2334.04608294931 2344.63647058824 2355.32621589561 2365.45748502994 2375.81961259080 2385.68466257669 2395.58478802993 2405.51194968553 2415.19211195929 2424.50709677419 2433.85039370079 2442.55978975033 2451.94101876676 2460.32479784367 2469.04377564980 2477.02200825310 2485.08495821727 2493.23809523810 2501.61276595745 2509.21325648415 2516.91159420290 2524.55964653903 2532.43387815750 2539.51274362819 2547.00455235205 2554.03703703704 2561.36939721793 2568.30685358255 2575.32176656151 2581.71860095390 2588.80317460317 2595.33386327504 2601.73003194888 2608.33006535948 2614.38398692810 2620.22795341098 2626.29950083195 2632.18686868687 2638.30034129693 2644.08233276158 2650.09230769231 2655.41166380789 2661.23529411765 2666.65391304348 2672.29100529101 2677.79322638146 2683.43963963964 2688.31588447653 2693.77396021700 2699.09854014599 2703.78727272727 2708.82935779817 2713.87316176471 2718.63401109057 2723.46728971963 2727.65485074627 2732.76603773585 2737.45419847328 2741.57442748092 2746.32882011605 2750.87719298246 2755.07677165354 2759.44356435644 2763.74749498998 2767.91919191919 2772.09572301426 2775.99168399168 2780.33333333333 2784.10351966874 2788.31524008351 2792.32008368201 2796.25847457627 2800.12903225806 2803.79175704989 2807.75599128540 2811.42825607064 2815.39606126915 2818.85176991150 2822.74610244989 2826.41610738255 2829.72045454545 2833.31292517007 2836.69107551487 2839.91685912240 2843.21658986175 2846.66744730679 2849.82159624413 2853.04716981132 2856.49408983452 2859.42553191489 2862.79616306954 2865.72901678657 2868.73557692308 2872.10436893204 2874.89603960396 2877.98756218905 2881.00997506234 2883.96491228070 2887.29591836735 2889.96212121212 2892.77577319588 2895.44559585492 2898.41361256545 2901.01827676240 2903.77248677249 2906.46010638298 2909.29946524064 2911.84239130435 2914.61788617886 2916.79781420765 2919.80874316940 2922.29972752044 2924.94535519126 2927.51366120219 2929.94505494506 2932.45257452575 2935.03814713896 2937.62534435262 2939.83888888889 2942.13407821229 2944.81232492997 2947.33519553073 2949.63352272727 2952.15492957747 2954.37005649718 2956.65168539326 2959.01424501425 2961.13960113960 2963.19428571429 2965.62500000000 2967.67638483965 2969.80289855072 2971.62170087977 2974.12865497076 2976.33333333333 2978.15339233038 2980.20238095238 2982.32748538012];
This is the calibration measurement, I need to find a suitable function for this dataset, because later, I need to extrapolate the data. I have successfully tried smoothing splines (in Python, because I don't have the Curve fitting toolbox), and they work ok for the above dataset. But this dataset is only a simulation, the real experiment will have more noise and smoothing splines might fail.
Does anyone have a tip for me....? Thanks!William Thielickehttps://jp.mathworks.com/matlabcentral/profile/authors/1377529-william-thielicketag:jp.mathworks.com,2005:Question/3368182017-04-23T16:25:37Z2019-10-19T02:50:56ZLivescript editor is always loading<</matlabcentral/answers/uploaded_files/75916/Untitled.jpg>>
After I open a new livescript, the loading bar in the middle of editor never disappears.
Also 'Open' 'Save' 'Print' buttons stays Gray. When I close the script matlab asks me if I want to save changes before exit (this is the only way to save the .mlx file).
I can compile live scripts.
I don't have any problem with regular script files.Arin Altuntashttps://jp.mathworks.com/matlabcentral/profile/authors/9462167-arin-altuntastag:jp.mathworks.com,2005:Question/4862332019-10-19T02:49:53Z2019-10-19T02:49:53ZLivescript is always loading macOS Catalina update Version 10.15Ever since I downloaded the macOS Catalina update version 10.15 my livescripts are unable to open. My livescript editor is always loading and I don't know how to fix it. My livescripts were working perfectly before the update. I've tried changing the region and restarting MATLAB but it does not seem to be working. Any advice? Shifnaz Ahmedhttps://jp.mathworks.com/matlabcentral/profile/authors/16113228-shifnaz-ahmedtag:jp.mathworks.com,2005:Question/4862082019-10-18T19:49:11Z2019-10-19T02:49:38ZProperty inspector can not be used any more on macI cannot use the property inspector in figure any more after the macos update.
dongfei chenhttps://jp.mathworks.com/matlabcentral/profile/authors/15895741-dongfei-chentag:jp.mathworks.com,2005:Question/4862042019-10-18T19:14:04Z2019-10-19T02:48:50Zsimulink undefined funciton or variablesI am doing a simulink project of robotic arm and this is my diagram so far.
You see the red color certain blocks, it says unrecognized function or variable. How do I fix this?
The bottom image shows what my diagram will look like and I can't seem to find big black box anywhere which connest my 4 outputs, x1,x2,x3,x4.
Any help please?
Avnish Patelhttps://jp.mathworks.com/matlabcentral/profile/authors/16580080-avnish-pateltag:jp.mathworks.com,2005:Question/4862312019-10-19T02:04:27Z2019-10-19T02:46:37ZWhy do my axis change dimensioins?Hi All, this code is supposed to plot a 3D surface and a contour plot of the function with wells at (-2, 2) and (3, -1). However, when I run the code, firstly, the wells are not in the right places, and the dimensions of the axis change as my inputs for x and y change (ie the position of the wells change). What am I doing wrong?
Here is my code,
function M = landscape(x, y)
M = H1(x, y) + H2(x, y);
function h1 = H1(x, y)
R1 = 2;
s1 = [-2;2];
n1 = 2;
h1 = (1./(1+(R1./sqrt((x-s1(1)).^2+(y(:)-s1(2)).^2)).^n1));
end
function h2 = H2(x, y)
R2 = 1;
s2 = [3;-1];
n2 = 1;
h2 = (1./(1+(R2./sqrt((x-s2(1)).^2+(y(:)-s2(2)).^2)).^n2));
end
subplot(1, 2, 1)
surf(M)
subplot(1, 2, 2)
contour(M)
end
And two different graphs the first with x and y -5:5 and the second with x and y -10:10
Notice how the position of the wells change?Dawid Britshttps://jp.mathworks.com/matlabcentral/profile/authors/16339176-dawid-britstag:jp.mathworks.com,2005:Question/4861872019-10-18T16:59:37Z2019-10-19T02:43:15Z4d plot in order to create a surface with density from 4 vectors ( coordinates of the dots). X, Y, Z and C is the color. Hi,
I wanto to create a 4d plot, like isosurface. The data is attached. 4 vectors, xyz and color.
The problem is that I only have 4 vectors, XYZ is position in the space which creates the object and c is the color of that point.
I am kind of lost. Maybe I need to use meshgrid but the vectors has 37k points.
Thanks
Rafael Freirehttps://jp.mathworks.com/matlabcentral/profile/authors/2343440-rafael-freiretag:jp.mathworks.com,2005:Question/4861152019-10-18T10:44:47Z2019-10-19T02:38:06ZHow an script for get the product of G(x)=(x-x1).*(x-x2)...(X-Xn)How whrit an script for get the product of G(x)=(x-x1)*(x-x2)*...(X-Xn) and graphic.
Urgent ⚠️⚠️⚠️FAYE EDGARDhttps://jp.mathworks.com/matlabcentral/profile/authors/16604098-faye-edgardtag:jp.mathworks.com,2005:Question/4862322019-10-19T02:05:26Z2019-10-19T02:34:18ZPLEASE HELP, I introduced the following code but it didn’t work properly and I am not getting the correct answers, it should be for v= 2.421 and for f=0.01254 at the end it shows WARNING: Matrix is singular to working precision (Referring to line 16)function y=newtonsistematub
xo=[1;0.00627];
syms v f
fname=[(f*(2750/0.450)*(v*v/19.62));(-2*log(((0.000025)/(0.450*3.71))+((2.51*(0.941*10^-6))/(v*0.450*sqrt(f)))*sqrt(f))-1)];
fprima=jacobian(fname)
tolerancia=1.e-10;
maxiter=30;
iter=1;
f=inline(fname);
jf=inline(fprima);
error=norm(f(xo(1),xo(2)),2);
fprintf('error=%12.8f\n',error);
while error>=tolerancia
fxo=f(xo(1),xo(2));
fpxo=jf(xo(1),xo(2));
x1=xo-inv(fpxo)*fxo;
fx1=f(x1(1),x1(2));
error=norm((fx1),2);
fprintf('Iter %2d raíz x=(%14.9f,%14.9f,%14.9f) f(x)=(%14.9f,%14.9f,%14.9f)\n',iter,x1(1),x1(2),fx1(1),fx1(2));
if iter>maxiter
fprintf('Numero de interacciones excedido\n');
return;
end;
xo=x1;
iter=iter+1;
endHildebrand Solishttps://jp.mathworks.com/matlabcentral/profile/authors/16115953-hildebrand-solistag:jp.mathworks.com,2005:Question/4862242019-10-18T23:47:52Z2019-10-19T02:28:35ZError using imread>get_full_filename (line 566) File "PAT\NPatsmall\0.tif" does not exist.good evening
i am new user for matlab so i try to collect images from many folder to get the DCT2, RGB histogram and indexed-color histogram features .
i got a error that file is not exist but i check it by my self it was there
i try to chang the file name but it make no diffrencese
this is the code
if any one can help
----------------------------------------------------------------------------
ind=0;
path=strcat('PAT\', www ,'\');
outputfile2=strcat(www);
outputfileName2=strcat(path,outputfile2);
outputfileName3=strcat(outputfile2);
for iiii=1:50 %loop over the 100 images in each category
iii = (jndex-1)*50 + iiii -1;
fileName1=strcat(num2str(iii,'%2d'),'.tif');
outputfile1=strcat(num2str(iii,'%2d'),'.feats');
fileName1=strcat(path,fileName1);
outputfileName=strcat(path,outputfile1);
%reading the image:
X= imread(fileName1);
Xg=rgb2gray(X);
------------------------------------------------------------------------------abdallah seraghttps://jp.mathworks.com/matlabcentral/profile/authors/16614806-abdallah-seragtag:jp.mathworks.com,2005:Question/4845402019-10-10T06:48:48Z2019-10-19T02:08:05Zbwboundaries関数についてです。画像のセグメンテーション後、
閾値を設定し、
画像の二値化、
’imfill’を用いた二値化画像の穴埋め、
’bwmorph’によるエッジ化、
’imbidilate’,’imfill’,’imerode’を用いたモルフォロジー処理、
二値化画像のクリーンナップを行ったあと、bwboundaries関数を使いたいのですが、うまくいきません。
jpg拡張子の画像を読み込ませています。
解決策はありますか？Nagae Ryoyahttps://jp.mathworks.com/matlabcentral/profile/authors/7977636-nagae-ryoyatag:jp.mathworks.com,2005:Question/4862212019-10-18T22:50:44Z2019-10-19T01:53:01Zcombination and their sum hi can you help me with this
4 2
5 7
3 1
Combination 1: 4,5,3
Combination 2: 4,5,1
Combination 3: 4,7,3
Combination 4:2,5,3
Combination 6: 2,7,1
Combination 7: 2,7,3
Combination 8: 2,5,1
Combination 9: 4,7,1
And sum of each combination
thanks sampath kumar punnahttps://jp.mathworks.com/matlabcentral/profile/authors/16131496-sampath-kumar-punnatag:jp.mathworks.com,2005:Question/4862272019-10-19T01:11:44Z2019-10-19T01:42:26Zcombinations and their sum A = [1 2;
1 2;
1 2
1 2];
m = size(A,1);
output = [];
for j = 1:2
output = [output; A(:,j)'];
for i = 1:m
output = [output; [A(1:i-1,j); A(i,3-j); A(i+1:end,j)]'];
end
end
sum=output
sumOutput = sum(output,2)
if you could run this code you can see
this code is missing few combinations like
1 1 2 2
1 2 1 2
1 2 2 1
2 2 1 1
2 1 2 1
2 1 1 2
took 1 and 2 digits to understand combinations clearly.
Is it possible to fix the above error?
Can I get a code for n rows and n columns?sampath kumar punnahttps://jp.mathworks.com/matlabcentral/profile/authors/16131496-sampath-kumar-punnatag:jp.mathworks.com,2005:Question/4860572019-10-18T07:17:10Z2019-10-19T01:30:18Z How to plot LTI system for below question.How to Plot the output of LTI system where input is 𝑥[𝑛] = [8,6,3,9] and system response, ℎ[𝑛] = [1,1,6,0] without using inbuilt command of MATLAB ?Aravind Tullurihttps://jp.mathworks.com/matlabcentral/profile/authors/16608167-aravind-tulluritag:jp.mathworks.com,2005:Question/4861162019-10-18T10:45:17Z2019-10-19T01:24:40ZNeed a help in this codeHi every one,
I wrote this code trying to embed and image as a secret image in a 2nd DWT level cover image by anding the secret image directly in the 2nd HH image
and that is working but reasambling the imag is not working with me, becouse the PSNR and MSE is giving zero and infinity and the images is attached to this Question.
I am donig this code for a reserch for me help is need ASAP
Thanks in advance
the code is :
clc, clear all, close all
%reading the cover image and difene the pixels
I = imread('67.bmp');
cover_image=I(:,:,1);
figure, imshow (cover_image);
% transforming (Cover_imag) into red chanal , later into blue chanal, to
% detected the difference in between.
R_imag = cover_image(:,:,1);
% now detect the eyes to be the madia to cary the information
EyeDetect = vision.CascadeObjectDetector('EyePairsmall');
BB = step(EyeDetect,R_imag);
hold on
rectangle('Position',BB,'LineWidth',4,'LineStyle','-','EdgeColor','b');
Y = imread('10-12.jpg');
Y1 = Y(:,:,3);
figure(4),imshow(uint8(Y1)); title('Stego image');
Y2 = imresize(Y1,[200 200]);
%% Apply the DWT on the left eye to hide the data at the HH2 level of the
% Haar wavelet transformation using addtion directly when detecting the left
% eye which is a croped area from the face
x=length(BB(:,4));
%To detect Eyes
I2 = imcrop(R_imag,BB(x,:));
figure,imshow(I2);
rectangle('Position',BB,'LineWidth',4,'LineStyle','-','EdgeColor','b');
%To detect the left
na1 = I2(:, 1 : floor(end/2.3));
%figure,imshow(na1);
%%here the left eye is the croped area and we can resize the left eye image
% and find the HH2 to make it ready for work
% converting the Left Eye into DWT and get the HH2
cc= imresize (na1,[400 400]); %# resize the image to be squear;
n = 256; %# Number of values per color component
Level = 2; %# Number of decompositions
LL = cell(1,Level); %# Approximation coefficient storage
LH = cell(1,Level); %# Horizontal detail coefficient storage
HL = cell(1,Level); %# Vertical detail coefficient storage
HH = cell(1,Level); %# Diagonal detail coefficient storage
startImage = cc;
for iLevel = 1:Level %# Apply nLevel decompositions
[LL{iLevel},LH{iLevel},HL{iLevel},HH{iLevel}] = dwt2(startImage,'haar');
startImage = LL{iLevel};
end
tiledImage = wcodemat(LL{Level},n);
for iLevel = Level:-1:1
tiledImage = cat(1,cat(2,tiledImage,...
wcodemat(LH{iLevel},n)),...
cat(2,wcodemat(HL{iLevel},n),...
wcodemat(HH{iLevel},n)));
end
figure;
imshow(uint8(tiledImage-1)); %# Convert to unsigned 8-bit integer to display
rr=(HH{1});
whos rr;
whos Y2
%%
rr2 = im2uint8(rr);
figure,imshow(uint8(rr2));
HH_Ori = rr2+ Y2;
figure, imshow (HH_Ori);
rr2 = HH_Ori;
imwrite(rr2,'HH_Ori.bmp')
%%%%%%% try to reconstruct the image %%%%%%%%%%%%%%%%%
HH_Ori = HH{1};
fullRecon =R_imag;
for i = n:1
fullRecon = idwt2(LL{i},LH{i},HL{i},fullRecon,'Haar');
end
whos fullRecon
figure(112),imshow(uint8(fullRecon));
%% Now applying PSNR & MSE %%%%%%%%%%%5
[rows, columns] = size(R_imag);
squaredErrorImage = (double(R_imag) - double(fullRecon)) .^ 2;
subplot(2, 2, 1);
imshow((squaredErrorImage, []));
title('Squared Error Image');
mse = sum(sum(squaredErrorImage)) / (rows * columns);
% Calculate PSNR (Peak Signal to Noise Ratio) from the MSE according to the formula.
PSNR = 20 * log10( (255) / mse);
% Alert user of the answer.
message = sprintf('The mean square error is %.2f.\nThe PSNR = %.2f', mse, PSNR);
msgbox(message);
Karbala'a Unvi. Sciencehttps://jp.mathworks.com/matlabcentral/profile/authors/4399013-karbala-a-unvi-sciencetag:jp.mathworks.com,2005:Question/4862262019-10-19T01:06:45Z2019-10-19T01:17:11ZError using vertcat, dimensions of arrays are not being concatenated are not consistent Hi I need help as I keeping seeing this error when inputing my code!
I have inputed:
for i=1:size(files,1)
X=load(files(i).name);
id= str2num(files(i).name(2:end-4));
output(id,1:3)=[id median(x.tempfile(x.tempfile(:,1)==1,2))
median(x.tempfile(x.tempfile(:,1)==2,2))]
end
As I am trying to find the median for each id number for my variables that I have downloaded for coloum 2 !! really appreciate if anyone could help:)
iihttps://jp.mathworks.com/matlabcentral/profile/authors/16502257-iitag:jp.mathworks.com,2005:Question/4862062019-10-18T19:35:15Z2019-10-19T01:01:10ZHow to Split excel file with multi columns into equal smalller excel files using matlabPlease how can splitting Excel file (n*m) into smallaer equal excel files by matalbFurat Alobaidyhttps://jp.mathworks.com/matlabcentral/profile/authors/6214076-furat-alobaidytag:jp.mathworks.com,2005:Question/4857722019-10-16T23:25:58Z2019-10-19T00:51:41ZColormap color levels on cursorI have a 3 column matrix which is x,y, and C. x and y values are coordinates and C value is intensity. I plot a diagram with using "patch" command.
On figure i just get x and y values on cursor. I want to see intenstiy values on colormap. How can i do it?
Note:
I have tried before meshgrid and countourf but it takes a lot of time to create figure because i have many data points. I use for loop for every rectangle so it takes a lot of time. When i do not use for loop it creates a wrong shape.
Anyone can help me?
Mooner Landhttps://jp.mathworks.com/matlabcentral/profile/authors/16254851-mooner-landtag:jp.mathworks.com,2005:Question/809002013-07-02T16:22:42Z2019-10-19T00:36:01ZImporting data from Excel to Matlab problemHi guys, I'm having a problem important datas from Excel. I used to import ranges because I found it easier, but now I need to gather a whole sheet from Excel. When I use xlsread, The import is working but the first row of my sheet, which contains the name of my variables disappears. I would like to keep em after important. Thank you in advance.Simonhttps://jp.mathworks.com/matlabcentral/profile/authors/4328543-simontag:jp.mathworks.com,2005:Question/4862112019-10-18T20:13:50Z2019-10-19T00:31:39ZSimulink 'To File' Block: How to save simulation outputs as distinct vectorsHi all,
How is it possible to save in simulink a bunch of simulation outpus in the same .mat file (using the 'To File' block), but with each variable being saved not as part of the same matrix but as distinct vectors?
For example, I currently use a Mux to bring 3 variables together into the same .mat file. All these 3 variables are then saved in a single matrix. I would like them to be saved distinctly as vectors (each with a name that I give them, either manually or taken from the simulation). Is this possible?
Thanks for your help in advance,
KMT.
P.S.
I would assume that the above would be possible if I could opt to save the data as a structure (as the documentation says) but for some reason this option is not available for me (I only have timeseries and array). I use 2018b versionKostashttps://jp.mathworks.com/matlabcentral/profile/authors/15803667-kostastag:jp.mathworks.com,2005:Question/4862172019-10-18T22:05:24Z2019-10-19T00:22:07ZHow to save score from game and then load it when second attempt is madeclear all
err = 0.1; %-- error margin
figure; hold on
xlim ([0 2])
ylim ([0 2])
score = 0; %-- number of correct hits
circleval = 40;
hit = true; %- will change to 'false' if target is not hit
tic
load score
while score < 6 %-- repeat loop until number of correct hits is 6
if hit
x=rand(1) %- location of target
y=rand(1)
a = rand(1)
b = rand(1)
c = rand(1)
d = rand(1)
e = rand(1)
f = rand(1)
hl = plot(x,y,'o')
hl(1).MarkerSize = circleval; % make the markersize the size of cicrcle value
hit = false
plot (a,b,'g o',c,d,'b o',e,f,'c o') % add 3 random circles
end
[x1 y1] = ginput(1) %- location of click
plot(x1,y1, '+')
dist = sqrt((x-x1)^2+(y-y1)^2); %-- distance between target and click
if dist< err
hit = true
score = score + 1
circleval = circleval - 5; % decrease the circle to 5 less each time
end
end
title(toc)
save score
clear all
return
%Qn 4
accuracyscore = dist*2 + toc
% Qn 2
if toc <= 10
disp ('You won GOLD')
elseif (toc >= 11 && toc<= 15)
disp ('You won SILVER')
elseif (toc >= 16 && toc<= 20)
disp ('You won BRONZE')
else
toc >= 21
disp ('No medal')
endAlly Kassamhttps://jp.mathworks.com/matlabcentral/profile/authors/16127411-ally-kassam