https://ch.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2021-06-23T14:26:03Ztag:ch.mathworks.com,2005:Question/8633652021-06-23T14:26:03Z2021-06-23T14:26:03Zhow can I do SSB Modulation and demodulation using matlab . The message signal m(t)is defined as audio signal of bandwidth 3.5KHz and carrier signal is defined as c(t)= cos (2 pi 7000t)
Generate the SSB AM signal u(t) using matlab simulink
Demodulate the audio signal from SSB AM signal & listen to it
Plot the spectra of m(t),c(t) and u(t) using matlab simulinkHema Bindu Karrihttps://ch.mathworks.com/matlabcentral/profile/authors/22388221tag:ch.mathworks.com,2005:Question/8629552021-06-23T04:22:25Z2021-06-23T14:23:03ZWhy is my CNN overfitting?I'm trying to train a convolutional neural network (CNN) to classify raw ECG signals. Successes indicate that defibrillation worked on the patient and failures indicate that defibrillation did not work. I've included the .mat file with all the data. The matrix vf represents all the signals while the string array, R, represents the labels. vf has 2078 rows for each patient and 760 columns for samples per signal.
My training plot looks like a classic case of overfitting and I have included the image below. My validation accuracy is consistently lower than my training accuracy and the validation loss increases over time. I've tried to introduce batch normalization, L2 regularization, and data augmentation into my neural network to no avail.
Are there errors with my neural network layers? It seems that no matter what I do, the validation accuracy will not go higher than 55%.
Thanks in advance.
load cnnData
miniBatchSize = 128;
maxEpochs = 150;
learnRate = 0.001;
out = mat2gray(vf); % Min-max normalizes signals
data = reshape(out,[1 size(out,2) 1 size(out,1)]);
labels = categorical(R);
% Determining indices of training, validation, and test data
[trainInd,valInd,testInd] = dividerand(size(out,1),0.7,0.15,0.15);
% Gathers training data and corresponding labels
XTrain = data(:,:,1,trainInd);
YTrain = labels(trainInd);
% Gathers testing data and corresponding labels
XTest = data(:,:,1,testInd);
YTest = labels(testInd);
% Gathers validation data and corresponding labels
XValidation = data(:,:,1,valInd);
YValidation = labels(valInd);
% Layers of Neural Network
layers = [imageInputLayer([1 size(out,2) 1])
convolution2dLayer([1, 15],16,'Padding',1)
reluLayer
dropoutLayer(0.4)
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer([1, 15],32,'Padding',1)
reluLayer
dropoutLayer(0.4)
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer([1, 15],64,'Padding',1)
reluLayer
dropoutLayer(0.4)
maxPooling2dLayer(2,'Stride',2)
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
% Training Options of Neural Network
options = trainingOptions('adam',...
'MiniBatchSize',miniBatchSize,...
'MaxEpochs',maxEpochs,...
'InitialLearnRate',learnRate,...
'ValidationData',{XValidation,YValidation},...
'Plots','training-progress',...
'Shuffle','every-epoch',...
'Verbose',true);
% Trains network and classifies test data
net = trainNetwork(XTrain,YTrain,layers,options);
Pred = classify(net,XTest);
% Creates confusion matrix
confMat = confusionmat(YTest,Pred);
Jared Stinsonhttps://ch.mathworks.com/matlabcentral/profile/authors/17471116tag:ch.mathworks.com,2005:Question/8631252021-06-23T08:42:14Z2021-06-23T14:22:02ZChange MaxFunctionEvaluations in optimization problemHi, everyone.
I'm doing an optimization problem, all works until I change the constraints when i make them more restrictive, cause the solver stopped prematurely. I tried to increase the function evaluation limit by using
options = optimoptions(@fmincon,'Algorithm','interior-point','MaxFunctionEvaluations',10000)
But nothing changed. How can I change the limit?
The script is as follows:
aymax = 5;
V = 70;
limro = aymax / (V/3.6)^2;
....
type objfun
rof1 = optimvar('rof1');
rof2 = optimvar('rof2');
....
sf4 = optimvar('sf4');
obj = fcn2optimexpr(@objfun,rof1,rof2,rof3,rof4,sf1,sf2,sf3,sf4);
prob = optimproblem('Objective',obj);
constr1 = rof1 >= 0;
prob.Constraints.curvatura1 = constr1;
constr2 = rof1 <= (-aymax / (V/3.6)^2)*0.8;
prob.Constraints.curvatura2 = constr2;
constr3 = rof2 >= -0.0005;
prob.Constraints.curvatura3 = constr3;
....
....
constr17 = sf4 >= intorno;
prob.Constraints.ascissa9 = constr17;
x0.rof1 = 0.1;
x0.rof2 = 0.2;
....
....
x0.sf4 = 30;
options = optimoptions(@fmincon,'Algorithm','interior-point','MaxFunEvals',10000);
[sol,fval,exitflag,output] = solve(prob,x0);Andrea Mazzettohttps://ch.mathworks.com/matlabcentral/profile/authors/12354589tag:ch.mathworks.com,2005:Question/8630502021-06-23T06:43:45Z2021-06-23T14:19:38Zcould to create the categorical values for 2x2 cell arrayI having cell array of 15x1. A (input training data for clustering)=15×1 cell array
{2×1 double}
{2×1 double}
{2×1 double}
{2×1 double}
{2×1 double}
{2×2 double}
{2×2 double}
{2×2 double}
{2×2 double}
{2×2 double}
{2×3 double}
{2×3 double}
{2×3 double}
{2×3 double}
{2×3 double}
B(targets for clustering) needs to be in the following manner.
[ 1
1
1
1
1
1 1
1 2
2 1
2 1
1 2
1 2 2
2 1 1
1 3 2
1 1 2
2 2 1]
Could you please help me to get it.
jaah navihttps://ch.mathworks.com/matlabcentral/profile/authors/11695462tag:ch.mathworks.com,2005:Question/1315352014-05-28T20:34:24Z2021-06-23T14:19:31Zwhat is the matlab code for ploting dispersion against wavelength (for chromatic dispersion)?I would like to get some matlab codes to draw graphs showing chromatic disperionTUMWESIGYE ABRAHAMhttps://ch.mathworks.com/matlabcentral/profile/authors/5339884tag:ch.mathworks.com,2005:Question/6641582020-11-27T00:36:31Z2021-06-23T14:18:58Z'deal' doesn't distribute the elements of a calculated array out of cellfunFor the following
syms syma symb
eqns = [...
syma*exp(symb)== 1,...
syma*exp(symb*1500) == 5,...
];
vars = [syma symb ];
[sola, solb ] = deal(cellfun(@(C) double(C),struct2cell(vpasolve(eqns,vars)),'UniformOutput',true)')
the ouput is
sola = 0.9989 0.0011
and
solb = 0.9989 0.0011
while, expectedly, sola should take only the first value 0.9989 and solb should take inly the second value 0.0011.Diaahttps://ch.mathworks.com/matlabcentral/profile/authors/3426444tag:ch.mathworks.com,2005:Question/8633502021-06-23T14:12:54Z2021-06-23T14:14:45ZModification needed in legend propertiesphi = 0.1; s = 0; b = 0.5; Da = 0.1; M = 1; D = 0; Pr = 6.2; Nr = 0.5;
for phi = [0.01 0.1 0.2]
rhof = 997.1; Cpf = 4179; kf = 0.613; betaTf = 21*10^-5; sigmaf = 5.5*10^(-6); % for WATER % % %
rhos = 8933; Cps = 385; ks = 401; betaTs = 1.68*10^-5; sigmas = 59.6*10^(6);betaCs = 3.05*10^(-6); % for Cu
% rhos = 3970; Cps = 765; ks = 40; betaTs = 0.85*10^-5; sigmas = 35*10^(6); % for Al2O3
% rhos = 2600; Cps = 425; ks = 6600; betaTs = 0.7*10^-10; sigmas = 101.32*10^6; % SWCNTs
A1 = ((1 - phi)^(2.5))*(1 - phi + phi*rhos/rhof); Sig = sigmas/sigmaf; A2 = ((1 - phi)^(2.5))*(1 + 3*(Sig-1)*phi/((Sig+2)-(Sig-1)*phi)); A3 = 1 - phi + phi*rhos*Cps/(rhof*Cpf);A4 = (ks+2*kf-2*phi*(kf-ks))/(ks+2*kf + 2*phi*(kf - ks));
ODE = @(x,y) [ y(2); y(3); -A1*( (y(1)+b*x/2)*y(3) - y(2)^2 + b*(y(2)^2-1) + 1 ) - (M*A2+Da)*(1-y(2)); y(5); A3*Pr*( (y(2)+b/2+D/A3)*y(4) - (y(1)+b*x/2)*y(5) )/(A4+Nr)];
BC = @(ya,yb)[ ya(1)-s; ya(2); ya(5)+(1/A4); yb(2)-1; yb(4) ]; xa = 0; xb = 4;xn = linspace(xa,xb,101); solinit = bvpinit(xn,[0 1 0 1 0]); sol = bvp5c(ODE,BC,solinit); S = deval(sol,xn);f0 = deval(sol,0);
Cf = f0(3)/(1-phi)^2.5; Nu = - f0(5)*A4;
figure(2),plot(xn,S(2,:),'b-','Linewidth',3);set(gca,'FontSize',22,'FontWeight','bold');hold on;xlabel('\bf\eta','Color','blue','FontSize',18);ylabel('\bff^{\prime}(\eta)','Color','blue','FontSize',22);
L(1) = plot(nan,nan,'b-','Linewidth',2);L(2) = plot(nan,nan,'r-','Linewidth',2);L(3) = plot(nan,nan,'g-','Linewidth',2);
legend(L,{'\color{blue}\bf\itCu ~ Water NANOFLUID','\color{red}\bf\itAl_2O_3 ~ Water NANOFLUID','\color{green}\bfSWCNT ~ Water NANOFLUID'},'FontSize',18);
legend boxoff;set(gcf,'Units','Normalized','OuterPosition',[0, 0.04, 1, 0.96]);
end
%% Code is OK, but I need to change L(1), L(2), L(3) as:
% L(1) = plot(nan,nan,{'b-','b--','b:'},'Linewidth',2);L(2) = plot(nan,nan,{'r-','r--','r:'},'Linewidth',2);
% L(3) = plot(nan,nan,{'g-','g--','g:'},'Linewidth',2);
%% Means in every LEGEND line should contain {solid, dotted, dashed}
MINATI PATRAhttps://ch.mathworks.com/matlabcentral/profile/authors/12692023tag:ch.mathworks.com,2005:Question/8633602021-06-23T14:14:31Z2021-06-23T14:14:31ZHow to Identify Image channel using Bio-Format Import?I have an Image and I am reading its metadata using bio-format "Bfopen()". I get 1x4 cell array containing metadata of the image, I want to identify channel of the image from this metadata obtained from bio-format, how can I do that?Mohsin Zubairhttps://ch.mathworks.com/matlabcentral/profile/authors/11104603tag:ch.mathworks.com,2005:Question/8633152021-06-23T12:55:20Z2021-06-23T14:13:49ZNot able to create exact .json from a structHello, I need to create a .json to make a request using an API. Using Python, it worked succesfully but with MATLAB I constantly get status 400 with "Bad Request". Since creating a .json in MATLAB is not as easy as in Python , I may be making some mistake creating the .json. Also, I already made another kind of request via MATLAB using .json to the same server, which worked fine. Here is the .json, that I need to create:
new_task = {
"task_type": "area",
"task_name": "area_request1",
"params":
{
"dates": [
{
"startDate": "01-01-2018",
"endDate": "02-14-2018"
}],
"layers": [
{
"layer": "SRTMGL3_DEM",
"product": "SRTMGL3_NC.003"
}],
"output":
{
"format":
{
"type": "geotiff"
},
"projection": "geographic"
},
"geo":
{
"type": "FeatureCollection",
"fileName": "User-Drawn-Polygon",
"features": [
{
"type": "Feature",
"properties":
{},
"geometry":
{
"type": "Polygon",
"coordinates": [
[
[5, 12],
[5, 13],
[6, 13],
[6, 12],
[5, 12]
]
]
}
}]
}
}
}
And here is the code to construct it in MATLAB:
% Area example
area_json_struct = struct();
area_json_struct.task_type = "area";
area_json_struct.task_name = "area_request1";
%% json_struct -> params
% json_struct -> params -> dates
startDate = ["01-01-2018"];
endDate = ["01-02-2018"];
area_json_struct.params.dates = table(startDate, endDate);
% json_struct -> params -> layers
layer = ["SRTMGL3_DEM"];
product = ["SRTMGL3_NC.003"];
area_json_struct.params.layers = table(layer, product);
% json_struct -> params -> output
area_json_struct.params.output.format.type = "geotiff";
area_json_struct.params.output.projection = "geographic";
% json_struct -> params -> Geo
% Siehe https://de.wikipedia.org/wiki/GeoJSON
area_json_struct.params.geo.type="FeatureCollection";
area_json_struct.params.geo.fileName="User-Drawn-Polygon";
area_json_struct.params.geo.features.type = "Feature";
area_json_struct.params.geo.features.properties = table();
area_json_struct.params.geo.features.geometry.type = "Polygon";
area_json_struct.params.geo.features.geometry.coordinates = [...
[5,12];...
[5,13];...
[6,13];...
[6,12];...
[5,12]...
];
area_payload = jsonencode(area_json_struct, 'PrettyPrint', true);
which results in:
area_payload =
'{
"task_type": "area",
"task_name": "test",
"params": {
"dates": [
{
"startDate": "01-01-2018",
"endDate": "01-02-2018"
}
],
"layers": [
{
"layer": "SRTMGL3_DEM",
"product": "SRTMGL3_NC.003"
}
],
"output": {
"format": {
"type": "geotiff"
},
"projection": "geographic"
},
"geo": {
"type": "FeatureCollection",
"fileName": "User-Drawn-Polygon",
"features": {
"type": "Feature",
"properties": [],
"geometry": {
"type": "Polygon",
"coordinates": [
[
5,
12
],
[
5,
13
],
[
6,
13
],
[
6,
12
],
[
5,
12
]
]
}
}
}
}
}'
Thank you for any help!Mert Asil Türelihttps://ch.mathworks.com/matlabcentral/profile/authors/14110246tag:ch.mathworks.com,2005:Question/8633552021-06-23T14:13:43Z2021-06-23T14:13:43ZHow to vectorize a for loop with array multiplication?Please help on replacing:
for i=1:Nm
Sloctemp(i,:,:)=Sloctemp(i,:,:)*Sort(m,i);
end
Where Nm = 19 Sloctemp is a 30x6x6 matrix, Sort is a 524288x19 matrix m=1
Sort is populated with only 0 or ones, so I am just trying to multiply Sloctemp(1:19,:,:) by either 1 or 0.
I tried:
i=1:Nm;
Sloctemp(i,:,:)=Sort(m,i).*Sloctemp(i,:,:);
but get the "Array dimensions must match for binary array op." error.
This section of the code gets run tens of millions of times, so I am just trying to get the fastes solution.
Thank you!Erin Pratthttps://ch.mathworks.com/matlabcentral/profile/authors/5407195tag:ch.mathworks.com,2005:Question/8627902021-06-22T20:21:03Z2021-06-23T14:07:51ZHow to solve 3 simultaneous algebraic equations with a equality constraint.If someone could help me to plot x1 vs t from the information. Please if someone could give any idea.
%Initial conditions
x1=140; x2=140; x3=140;
%Equations
x1 =t*x1+x2+t*x3;
x2 = 2*t*x1+t*x2+x3;
x3 = t*x1+x2+x3;
% Equality constraint
x1+x2+x3=420;Shivanshu Tripathihttps://ch.mathworks.com/matlabcentral/profile/authors/22194002tag:ch.mathworks.com,2005:Question/8630052021-06-23T05:49:48Z2021-06-23T14:03:50Zhow to save values for changing number of columns using "for loop "I want to run a simple code, but i am unable to get the results correctly. A simple code is wriiten below, I am changing number of columns of one parameter. for that i want to save value of X_telda (10), X_telda(50) and X_telda(100) separately. U and X are given matrices.
for r=[10 50 100];
X_telda=(U(:,1:r)*(U(:,1:r)'*X));
end
thank youKhanhttps://ch.mathworks.com/matlabcentral/profile/authors/21229238tag:ch.mathworks.com,2005:Question/2596322015-12-10T05:00:00Z2021-06-23T14:03:04ZHow can I get MATLAB installation files for use on an offline machine?I need to install MATLAB on an offline machine and I understand that the installer downloaded from the MathWorks website does not contain the necessary files. How can I get these files?MathWorks Support Teamhttps://ch.mathworks.com/matlabcentral/profile/authors/4622813tag:ch.mathworks.com,2005:Question/4223092018-10-05T08:14:50Z2021-06-23T14:01:09ZChange if -statement by userinputIs it possible to change an if condition by a User input? E.g. I have a dropdown menu with the options ('<','>') and an if condition (if i>5 ....)
I want to adapt my if-condition to the selected option in the dropdown menu. So if I choose '<' in the dropdown menu, my if condition changes from (if i>5 to if i<5).
Matthias Bergerhttps://ch.mathworks.com/matlabcentral/profile/authors/13471394tag:ch.mathworks.com,2005:Question/8631702021-06-23T09:46:05Z2021-06-23T13:59:45ZDivide histogram bins by timeHello
So I have processed data and want to present it as frequency over time. I used datenum to get timevectors but I don't know how to chose the binwidth to encompass one month since month is irregular. The code below does plot it in time but I am not sure how the values like "737287" referes to a particular date. Dividing a year by 12 would also be sufficient as it is not very important which month it is but I have failed in this as well. The starting/end dates is not static either as more data will come.
Any help would me much appreciated.
Thank you in advance.
TimeNS = datenum(NotScaled(:,3), 'dd-mm-yyyy')
h1 = histogram(Time)
datetick('x','dd-mm-yyyy')Måns Lundberghttps://ch.mathworks.com/matlabcentral/profile/authors/10253685tag:ch.mathworks.com,2005:Question/8633452021-06-23T13:59:24Z2021-06-23T13:59:24ZSAC RL agent does not explore properly (rlSACAgent)Hi,
I'm trying to create a SAC RL agent. The agent can set 8 separate continuous actions with the same upper and lower bound (-10 and 10).
During training I observe that the actions chosen are (almost!) always one of the two bounds. So they often fluctuate between the minimum or the maximum. Sporadically another value is chosen for one of the actions.
I've found a similar question HERE, but the answer given did not solve the issue. (The range of the action space for all actions is already the same, and EntropyWeight did not change anything). Besides, I've tried to scale the reward, such as suggested in this article.
Are there any other methods for solving such problem? Or could it be that the must have some patience, and train the agent for more episodes, such that the problem is solved by itself?
Thanks in advance for any reply.
Kind regards,Willemijn Remmerswaalhttps://ch.mathworks.com/matlabcentral/profile/authors/5719740tag:ch.mathworks.com,2005:Question/8627152021-06-22T18:50:45Z2021-06-23T13:53:53ZSaving data after each iterationHello so I'm trying something a bit different then before, so my code is as follows:
all_pulse = [ ];
files = importdata('name_files2.txt');
for i = 1:length(files)
[C_pulse, D_pulse] = One_Person(files{i}); %this is a pre-defined function
save('all_pulse', 'C_pulse', 'D_pulse') %what I have so far
end
The only thing I am having trouble with is that I want to save the outputs of my function (C_pulse and D_pulse) into the matrix all_pulse after each iteration of the loop so that I have all the data I need from each file in the larger matrix. Not sure how to do this. Thanks,Sydney Kehoehttps://ch.mathworks.com/matlabcentral/profile/authors/22734417tag:ch.mathworks.com,2005:Question/8632752021-06-23T12:09:41Z2021-06-23T13:52:53ZHow to add text on the figure without unknown x and y coordinates ?Hi i have a csv file the problem is my data has random x,y values so it changes according to machine but i want to display a value on the figure. I tried something like this v = (intensity/intensity_max)*100; text(x,y,(v) but it didn't work because of the x and y values. How can i overcome on this problem ? Onur Hakverdihttps://ch.mathworks.com/matlabcentral/profile/authors/22005875tag:ch.mathworks.com,2005:Question/8610902021-06-21T02:26:07Z2021-06-23T13:50:42Zbonjour pouvez me dire comment inserer ces equations dans le matlab plzbadreddine bensafiahttps://ch.mathworks.com/matlabcentral/profile/authors/22024479tag:ch.mathworks.com,2005:Question/8627452021-06-22T19:17:28Z2021-06-23T13:49:29ZNeed to calculate the mean without considering the 0 counts. In [1 2 3 4 0 6 7], mean should be (1+2+3+4+6+7)/6 and then output place the mean of six number at place of 0.MUDDASAR AYYUBhttps://ch.mathworks.com/matlabcentral/profile/authors/15761954tag:ch.mathworks.com,2005:Question/8633402021-06-23T13:48:41Z2021-06-23T13:49:16ZRF Blockset S-Parameters frequency vectorHello,
I'd like to simulate a S-parameter block (network-parameters as datasource) over a specific frequency range. Therefore, I need to enter a vector as frequency parameter. I defined the frequency vector in the base workspace via the linspace function. However, if I try to enter the name of that vector in the frequency field and apply these changes, the following error occurs:
"Failed to evaluate mask initialisation commands" and
"Caused by: Network parameter data is incomplete"
Why do I need to specify a frequency? If network-parameters are selected as datasource, the s-parameters stay the same over the whole frequency range, don't they? Or do I need to enter the s-parameters for every frequency point of the frequency vector?ToKahttps://ch.mathworks.com/matlabcentral/profile/authors/21451220tag:ch.mathworks.com,2005:Question/8627002021-06-22T18:45:53Z2021-06-23T13:47:40ZHow to get encoder and decoder parts of autoencoder in order to stack them?Hey,
I want to represent 128x128 images in a 1x64 vector, and for that I want to use autoencoders.
I have trained autoencoders in stages following the example in "Train Stacked Autoencoders for Image Classificatio".
However, I dont want to build a classifier, I want to build an autoencoder to embedd images.
(I tried build my own autoencoder with CNNs without using the built in autoencoder functions but I can't get good results for some reason)
Following the example I created two autoencoders, and added another one of my own instead of the softmax output and trained them:
encoder1 : 128x128 ->256-> 128x128
encoder2 : 256->128->256
encoder3 : 128->64->128
But how do I combine them?
If I use the "stack" function on these encoders like in the example:
stackednet = stack(encoder1,encoder2,encoder3)
I get this transformation :
128x128 -> 256 -> 128 -> 64
but what I want is this:
128x128 -> 256 -> 128 -> 64 ->128 -> 256 -> 128x128
So basicaly I need to stack this:
stackednet = stack(encoder1-encoder,encoder2-encoder,encoder3-encoder,encoder3-decoder,encoder2-decoder,encoder1-decoder)
Is there a way to extract the encoder and the decoder parts from an Autoencoder object and then stack them?ytzhak gousshahttps://ch.mathworks.com/matlabcentral/profile/authors/11482545tag:ch.mathworks.com,2005:Question/7707382021-03-12T12:25:17Z2021-06-23T13:46:07ZStop & pause a simulation in app designer using push buttonHi !
I would like to configure 2 push buttons in appdesigner, one of which will pause the running simulation, and another will stop the running simulation when clicked. What syntax should I use to get this worked ?
I have used "sim" command to run the simulation.Amit Patankarhttps://ch.mathworks.com/matlabcentral/profile/authors/19420105tag:ch.mathworks.com,2005:Question/4701112019-07-03T16:30:31Z2021-06-23T13:45:46ZMATLAB Answers Wish-list #5 (and bug reports)This is the 5th installment of the wish-list and bug report thread.
This topic is the follow on to the first Wish-list for MATLAB Answer sections and second MATLAB Answers Wish-list #2 (and bug reports). The third started out as New design of the forum - grey on white and the fourth MATLAB Answers Wish-list #4 (and bug reports) is also growing so large it is slow to load and navigate.
Same idea as the previous ones: one wish (or bug report) per answer, so that people can vote their wishes.
What should you post where?
Wishlist threads (#1 #2 #3 #4 #5): bugs and feature requests for Matlab Answers
Frustation threads (#1 #2): frustations about usage and capabilities of Matlab itself
Missing feature threads (#1 #2): features that you whish Matlab would have had
@anyone posting a new thread when the last one gets too large (about 50 answers seems a reasonable limit per thread), please update this list in all last threads. (if you don't have editing privileges, just post a comment asking someone to do the edit)Rikhttps://ch.mathworks.com/matlabcentral/profile/authors/3073010tag:ch.mathworks.com,2005:Question/8633352021-06-23T13:45:23Z2021-06-23T13:45:23Zwhen I ran a MATLAB app I created I get Warning: Marker input is ignored in command prompt. What this meansMarker input is ignoredNitin Phadkulehttps://ch.mathworks.com/matlabcentral/profile/authors/21532342tag:ch.mathworks.com,2005:Question/8632452021-06-23T11:24:21Z2021-06-23T13:42:45ZSolve function is unable to return the results of System of equations in the desired single number format instead of fraction ? help% In am interested in obtaining Steady state solution of 6 state ergodic
% continuous time markov chain where the long term probabilies in each
% state is given by Vector P = [ p1 p2 p3 p4 p5 p6] and
% State Transition rate matrix A wehre
% A =[-0.00074 0.00062 0.00012 0 0 0;
% 30 -30.00077 0.00031 0.00046 0 0;
% 0 0 -0.00012 0.00012 0 0;
% 0 0 0 - 0.00063 0.0004 0.00023;
% 2 0 0 0 -2 0 ;
% 0.2 0 0 0 0 -0.2]
% We obtain p1, p2 ...p6 by solving Equation 1 & 2 below:
% P*A = 0 .... Equation 1
% p1+p2+p3+4+p5+p6 = 1 ..... Equation 2
%
format long
syms eqn1 eqn2 eqn3 eqn4 eqn5 eqn6 eqn7 eqns sol p1sol p2sol p3sol p4sol p5sol p6sol p1 p2 p3 p4 p5 p6
eqn1 = -p1*0.00074+p2*30+ p5*2 + p6*0.2 == 0
eqn2 = p1*0.00062 - p2*30.00077 == 0;
eqn3 = p1*0.00012 +0.00031*p2 - p3*0.00012 == 0;
eqn4 = p2*0.00046 +p3*0.00012- p4*0.00063 == 0;
% eqn5 = p4*0.0004 - p5*2 == 0; we drop this equation and use eqn7 below
% for obatining p1, p2 ...p6
eqn6 = p4*0.00023 - p5*0.2 == 0;
eqn7 = p1+p2+p3+p4+p5+p6==1;
eqns = [eqn1, eqn2, eqn3, eqn4, eqn6, eqn7]
sol = solve([eqns],[p1,p2,p3,p4,p5,p6]);
format short
p1sol = sol.p1
p2sol = sol.p2
p3sol = sol.p3
p4so4 = sol.p4
p5so5 = sol.p5
p6so6 = sol.p6
p1sol = sol.p1
p2sol = sol.p2
p3sol = sol.p3
p4so4 = sol.p4
p5so5 = sol.p5
p6so6 = sol.p6
>> Solve_ergodic_ctmc
eqn1 =
30*p2 - (37*p1)/50000 + 2*p5 + p6/5 == 0
eqns =
[30*p2 - (37*p1)/50000 + 2*p5 + p6/5 == 0, (31*p1)/50000 - (8444466037051747*p2)/281474976710656 == 0, (3*p1)/25000 + (31*p2)/100000 - (3*p3)/25000 == 0, (23*p2)/50000 + (3*p3)/25000 - (63*p4)/100000 == 0, (23*p4)/100000 - p5/5 == 0, p1 + p2 + p3 + p4 + p5 + p6 == 1]
p1sol =
16625042510445626906250000/36395607773662890434476703
p2sol =
343575393447444480000/36395607773662890434476703
p3sol =
16625930080212032804490000/36395607773662890434476703
p4so4 =
3167094689375285334920000/36395607773662890434476703
p5so5 =
3642158892781578135158/36395607773662890434476703
p6so6 =
-26445240656283633798455/36395607773662890434476703
Vijaya Kumar Kondaguntahttps://ch.mathworks.com/matlabcentral/profile/authors/22873499tag:ch.mathworks.com,2005:Question/8632102021-06-23T10:12:01Z2021-06-23T13:39:29Z How to set the boundary value of the integral function as a variableHallo, I have a trouble with integral function. I want to calculate the coincident area of two Geometric shape. one is
rectangle, the other is circle. But the retangle can move with variable t.
So I don't know how to use the function command and integral function correct.
f=@(x)sqrt(3600-x^2)-10
so I write this function to calculate the coincident.area and at this moment the boundary is [-10, 10].
But if I want to let the boundary as variable such as [t-10,t+10] t=[-70:70]
And I want to get all the coincident area when the rectangle through pass the circle.
so how can I make it possible?Xiuyu Yanghttps://ch.mathworks.com/matlabcentral/profile/authors/20162507tag:ch.mathworks.com,2005:Question/8630452021-06-23T06:39:57Z2021-06-23T13:34:58ZHello, I'm a student and I look for a solution for Matlab. I'm quite beginner to use Matlab. Could you pls help me to write it through Matlab? I need how to write these codes JALALUDIN ARIShttps://ch.mathworks.com/matlabcentral/profile/authors/22889241tag:ch.mathworks.com,2005:Question/8632952021-06-23T12:26:20Z2021-06-23T13:33:10Zhow can i write function with the picture which i attached to the question?hey people
have a good time
i have a problem over the function which i attached to this Question.
i would like to write the function which take 2 variables (e.g. t and o)
and compute rmse and r^2 coefficient
can you help me out over this problem?
hadi mehttps://ch.mathworks.com/matlabcentral/profile/authors/22283975tag:ch.mathworks.com,2005:Question/4139702018-08-07T21:33:23Z2021-06-23T13:32:32Zcheck if cell within cell arrayI want to check if a cell is in the cell array. For example:
C = {{1,2};{4,5,6};{3,7}};
t = {3,7}
I want to know if t is the member of C. Instead of using loop, do we have functions?Lu Zhanghttps://ch.mathworks.com/matlabcentral/profile/authors/7997678tag:ch.mathworks.com,2005:Question/7532492021-02-23T01:09:06Z2021-06-23T13:23:31ZImatest esfrChart. Detected gray patches may not be correct. Hi, I'm trying to use the esfrChart() function to analyze a set of images. On roughtly 20% of the images, matlab throws the following error:
Detected gray patches may not be correct. Check if image is valid and consider changing detection sensitivity in case no registration points are provided.
The images are extremely similar. This first image works:
This second one throws the error:
I've tried inputting the registration points myself as well as changing the sensitivity, which didn't help. I also tried cropping the images in case the distortion near the edges was affecting things, but cropping didn't change which images work and don't work either.
What is this verification step where this error is thrown and is there a way around it? Is there anything that could be done when taking the images to make them work better?Sara Nagelberghttps://ch.mathworks.com/matlabcentral/profile/authors/20688879tag:ch.mathworks.com,2005:Question/8632302021-06-23T10:47:43Z2021-06-23T13:23:10ZError using Kaczmarz and use of rank and nullHow would I correct my code to get the correct values for e? I.e. not 5.
I want to compute the corresponding projection data b = Ax and perform enough iterations with Kaczmarz's method to ensure that the iterations have converged. However, my converged value keeps appearing as 5, which is incorrect.
s = 1/sqrt(2);
A = [1 1 1 0 0 0 0 0 0; 0 0 0 0 0 0 1 1 1; 1 0 0 1 0 0 1 0 0; 0 0 1 0 0 1 0 0 1; s s 0 s 0 0 0 0 0; 0 0 0 0 0 s 0 s s; 0 0 0 s 0 0 s s 0; 0 s s 0 0 s 0 0 0];
x = [1; 2; 3; 4; 5; 6; 7; 8; 9];
b = A*x
b =
6.0000
24.0000
12.0000
18.0000
4.9497
16.2635
13.4350
7.7782
k = [5,10,15,20,25];
X = kaczmarz(A,b,k);
e = zeros(length(k),1)
e =
0
0
0
0
0
for i=1:length(k), e(i) = norm(x-X(:,i),inf); end
e
e =
5
5
5
5
5
Ryan Philipshttps://ch.mathworks.com/matlabcentral/profile/authors/21444057tag:ch.mathworks.com,2005:Question/8631352021-06-23T09:06:48Z2021-06-23T13:22:46ZWhy the energy value is constant?clear
clc
I=0.0308;
p=7850;
X=1:1:10 ;
y = zeros(size(X));
d = zeros(size(X));
g = zeros(size(X));
for i = 1:length(X)
x = X(i) ;
fprintf("\nWhen the ratio , x = %.1f", x)
radius=(((2*I*x)/(p*3.142))^0.2);
fprintf("\nThe radius is %.3fm", radius)
thickness=radius/x;
mass=(p*(3.142*(radius*radius)*thickness));
fprintf("\nThe mass is %.3fkg", mass)
energy=((mass)*((radius*radius)*(W*W)))/2;
fprintf("\nThe energy is %.3fW\n", energy)
y(i) = radius;
d(i) = mass;
g(i) = energy;
end
figure
plot(y,g,'-*'), xlabel('Radius'), ylabel('Energy'), title('Energy vs Radius')
figure
plot(d,g, '-*'), xlabel('Mass'), ylabel('Energy'), title('Energy vs Mass')
MG NNhttps://ch.mathworks.com/matlabcentral/profile/authors/18287546tag:ch.mathworks.com,2005:Question/8561002021-06-14T17:13:24Z2021-06-23T13:18:40ZHelp with data mappingHi All
I hope you are well.
I have the following piece of code to process the data in the excel file attached ('ex1'), I want to map the output of the code E25-50, H25-50, and CCS25-50 into their respective columns in the new excel file ('Mapping') attached. Any idea please how to do it?
Note that for example CCS25 only contain 3 values according to their respective sectors. Therefore, when mapping, the values should correpsond to the correct sector in the file 'Mapping'.
Thanks,
Please see the attached Excel files after running the code.
[~, ~, numberandtext] = xlsread('ex1.xlsx');
str=numberandtext;
[ii1,jj1,kk1]=unique(str(:,2));
[ii2,jj2,kk2]=unique(str(:,4));
[ii3,jj3,kk3]=unique(str(:,6));
[ii4,jj4,kk4]=unique(str(:,8));
[ii5,jj5,kk5]=unique(str(:,10));
[ii6,jj6,kk6]=unique(str(:,12));
[ii7,jj7,kk7]=unique(str(:,14));
[ii8,jj8,kk8]=unique(str(:,16));
[ii9,jj9,kk9]=unique(str(:,18));
[ii10,jj10,kk10]=unique(str(:,20));
[ii11,jj11,kk11]=unique(str(:,22));
[ii12,jj12,kk12]=unique(str(:,24));
E25=[ii1 num2cell(accumarray(kk1,[str{:,1}]'))];
E25(cellfun(@(x) ~x(1),E25(:,2)),:) = [];
H25=[ii2 num2cell(accumarray(kk2,[str{:,3}]'))];
H25(cellfun(@(x) ~x(1),H25(:,2)),:) = [];
CCS25=[ii3 num2cell(accumarray(kk3,[str{:,5}]'))];
CCS25(cellfun(@(x) ~x(1),CCS25(:,2)),:) = [];
E30=[ii4 num2cell(accumarray(kk4,[str{:,7}]'))];
E30(cellfun(@(x) ~x(1),E30(:,2)),:) = [];
H30=[ii5 num2cell(accumarray(kk5,[str{:,9}]'))];
H30(cellfun(@(x) ~x(1),H30(:,2)),:) = [];
CCS30=[ii6 num2cell(accumarray(kk6,[str{:,11}]'))];
CCS30(cellfun(@(x) ~x(1),CCS30(:,2)),:) = [];
E40=[ii7 num2cell(accumarray(kk7,[str{:,13}]'))];
E40(cellfun(@(x) ~x(1),E40(:,2)),:) = [];
H40=[ii8 num2cell(accumarray(kk8,[str{:,15}]'))];
H40(cellfun(@(x) ~x(1),H40(:,2)),:) = [];
CCS40=[ii9 num2cell(accumarray(kk9,[str{:,17}]'))];
CCS40(cellfun(@(x) ~x(1),CCS40(:,2)),:) = [];
E50=[ii10 num2cell(accumarray(kk7,[str{:,19}]'))];
E50(cellfun(@(x) ~x(1),E50(:,2)),:) = [];
H50=[ii11 num2cell(accumarray(kk8,[str{:,21}]'))];
H50(cellfun(@(x) ~x(1),H50(:,2)),:) = [];
CCS50=[ii12 num2cell(accumarray(kk9,[str{:,23}]'))];
CCS50(cellfun(@(x) ~x(1),CCS50(:,2)),:) = [];
AHMED FAKHRIhttps://ch.mathworks.com/matlabcentral/profile/authors/5718026tag:ch.mathworks.com,2005:Question/8626802021-06-22T18:11:27Z2021-06-23T13:17:13ZConverting pixel intensity to temperature from TIFF image - Grayscale values much lower than expectedHello all,
I am working on a matlab script to input a TIFF file that was converted from RAW using the open source program dcraw. I am then loading the TIFF into the matlab script and using some conversions, getting temperature from intensity. There are three methods in the code Green/Red intensity ratio, grayscale intensity, and a hybrid that combines both. My issue lies in the grayscale values, which are derived from the RGB values, being much lower than the G/R ratio results when they should be relatively close. I am not sure what is wrong or why this is happening. Perhaps I am not handling the grayscale math correctly or if there is something wrong with the RAW->TIFF conversion.
The script is here:
NOTE: unfortunately the pixel->temperature conversion equations are proprietary and I cannot share them but they are from peer-reviewed literature so they are likely not the cause of the discrepancy. If no other issues are found I may look into those equations specifically though.
clear all
tic
format long g
myFolder = 'Your directory with the TIFF';
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.tiff'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1: length(theFiles)
photoname = theFiles(k).name;
fullFileName = fullfile(theFiles(k).folder, photoname);
A = imread(fullFileName);
rdc = 7.7;
gdc = 11.5;
bdc = 4.4;
GSdc = (rdc+gdc+bdc)/3;
iso = 6400;
t = 0.2;
f = 2.4;
y1 = 2000; % Entire picture is 5496 by 3672 pixels.
y2 = 2150;
x1 = 1800;
x2 = 2200;
nrows = y2 - y1;
ncolumns = x2 - x1;
rows = linspace(y1,y1+nrows-1,nrows);
for i = 1:ncolumns
c(i,1:nrows) = linspace(x1+i-1,x1+i-1,nrows);
end
for i = 1:ncolumns
RGB(1:nrows,(((4*i)-3):((4*i)-1))) = impixel(A,c(i,1:nrows),rows);
end
%% Separating RGB columns
rawred = RGB(1:end,1:4:end);
rawred2 = zeros(nrows,ncolumns);
for i = 1:nrows
for j = 1:ncolumns
if rawred(i,j) > 65534
rawred2(i,j) = 0;
else
rawred2(i,j) = rawred(i,j);
end
end
end
rawgreen = RGB(1:end,2:4:end);
rawblue = RGB(1:end,3:4:end);
%% Normalized Intensities
rawGS = (rawred2+rawgreen+rawblue)/3;
normred = ((rawred2-rdc)*(f^2))/(iso*t);
normgreen = ((rawgreen-gdc)*(f^2))/(iso*t);
normblue = ((rawblue-bdc)*(f^2))/(iso*t);
normGS = ((rawGS-GSdc)*(f^2))/(iso*t);
%% Finding log of pixel G/R ratio to use for ratio pyrometry curve fit
GR = normgreen./normred;
GR2 = log10(GR);
IP = imag(GR2);
logGR = zeros(nrows,ncolumns);
for i=1:nrows
for j=1:ncolumns
if IP(i,j) > 0
logGR(i,j) = 0;
else
logGR(i,j) = GR2(i,j);
end
end
end
%% Finding log of pixel Grayscale ratio
GS2 = log10(normGS);
IPGS = imag(GS2);
logGS = zeros(nrows,ncolumns);
for i=1:nrows
for j=1:ncolumns
if IPGS(i,j) > 0
logGS(i,j) = 0;
else
logGS(i,j) = GS2(i,j);
end
end
end
%THIS SECTION HAS BEEN CHANGED DUE TO RESTRICTIONS ON RELEASE OF
%PROPRIETARY INFORMATION
%% Application of ratio pyrometry curve fit
RT = (1*(logGR.^3) + 1*(logGR.^2) + 1*(logGR) + 1); % New Camera Ratio Temp
%% Grayscale Pyrometry Fit
GST = (1.*(logGS.^2))+(1.*logGS)+1;
%% Hybrid Pyrometry Method
HT = 1
%% Removal of 600-1200 range (Ratio)
%END OF SECTION
RT2 = zeros(nrows,ncolumns);
for i=1:nrows
for j=1:ncolumns
if RT(i,j) < 600
RT2(i,j) = 0;
elseif RT(i,j) > 1200
RT2(i,j) = 0;
else
RT2(i,j) = RT(i,j);
end
end
end
%% Removal of 600-1200 range (Grayscale)
GST2 = zeros(nrows,ncolumns);
for i=1:nrows
for j=1:ncolumns
if GST(i,j) < 600
GST2(i,j) = 0;
elseif GST(i,j) > 1200
GST2(i,j) = 0;
else
GST2(i,j) = GST(i,j);
end
end
end
%% Removal of 600-1200 range (Hybrid)
HT2 = zeros(nrows,ncolumns);
for i=1:nrows
for j=1:ncolumns
if HT(i,j) < 600
HT2(i,j) = 0;
elseif HT(i,j) > 1200
HT2(i,j) = 0;
else
HT2(i,j) = HT(i,j);
end
end
end
%% 50% rule (Ratio)
RT3 = zeros(nrows,ncolumns);
for i = 4:(nrows-4)
for j = 4:(ncolumns-4)
if nnz(RT2(i-3:i+3,j-3:j+3)) < 25
RT3(i,j) = 0;
else
RT3(i,j) = RT2(i,j);
end
end
end
%% 50% rule (Grayscale)
GST3 = zeros(nrows,ncolumns);
for i = 4:(nrows-4)
for j = 4:(ncolumns-4)
if nnz(GST2(i-3:i+3,j-3:j+3)) < 25
GST3(i,j) = 0;
else
GST3(i,j) = GST2(i,j);
end
end
end
%% 50% rule (Hybrid)
HT3 = zeros(nrows,ncolumns);
for i = 4:(nrows-4)
for j = 4:(ncolumns-4)
if nnz(HT2(i-3:i+3,j-3:j+3)) < 25
HT3(i,j) = 0;
else
HT3(i,j) = HT2(i,j);
end
end
end
%% MATLAB display
%RT4 = flip(RT3);
RT4=RT3;
GST4=GST3;
HT4=HT3;
RATraw = mean(nonzeros(RT4));
RatioAverageTemp = RATraw(~isnan(RATraw))
GSATraw = mean(nonzeros(GST4));
GrayscaleAverageTemp = GSATraw(~isnan(GSATraw))
HATraw = mean(nonzeros(HT4));
HybridAverageTemp = HATraw(~isnan(HATraw))
figure(1)
P = imagesc(RT4,[600 1200]);
shading interp
colormap jet
colorbar;
title([photoname ' Green-Red Ratio Analysis']);
xlabel(['Ratio Average Temperature = ' num2str(RatioAverageTemp)]);
figure(2)
Q = imagesc(GST4,[600 1200]);
shading interp
colormap jet
colorbar;
title([photoname ' Grayscale Analysis']);
xlabel(['Grayscale Average Temperature = ' num2str(GrayscaleAverageTemp)]);
figure(3)
R = imagesc(HT4,[600 1200]);
shading interp
colormap jet
colorbar;
title([photoname ' Hybrid Analysis']);
xlabel(['Hybrid Average Temperature = ' num2str(HybridAverageTemp)]);
toc
%% Statistics
RSTD = std(nonzeros(RT4));
GSSTD = std(nonzeros(GST4));
HSTD = std(nonzeros(HT4));
RSNR = RatioAverageTemp/RSTD
GSSNR = GrayscaleAverageTemp/GSSTD
HSNR = HybridAverageTemp/HSTD
RatioCI95 = (1.96*RSTD)/sqrt(nnz(RT4))
GrayscaleCI95 = (1.96*GSSTD)/sqrt(nnz(GST4))
HybrdiCI95 = (1.96*HSTD)/sqrt(nnz(HT4))
end
Here are the RAW and TIFF images. For those familiar with dcraw the input command used was
dcraw -v -w -H 0 -o 1 -q 3 -4 -T
in command line using dcraw v9.27
RAW IMAGE
TIFF Conversion
Hopefully the google drive links dont change the files from how they are stored originally. Mahdi Tlemsanihttps://ch.mathworks.com/matlabcentral/profile/authors/11114598tag:ch.mathworks.com,2005:Question/8628702021-06-23T00:55:19Z2021-06-23T13:16:00ZEfficient algorithm to compute only the most probable sequences of a random variable out of all possible sequencesI'm looking for a better way to compute the possible sequences of a random variable whos value at time k is given by.
x(k) = 1 with probability p(1), 2 with probability p(2), ... np with probability p(np).
However, since the number of possible sequences increases exponentially with n and np, I only want to compute the most probable sequences which have a combined probability less than a threshold p_cut.
I've devised a function to do this below but it has two major drawbacks.
It doesn't generalize to sequences longer than 3.
It is quite memory inefficient since it always computes all possible permutations when only a subset may be needed.
function S = most_probable_sequences(p, n, p_cut)
assert(sum(p) == 1);
np = numel(p);
switch n
case 1
all_perms = (1:np)';
case 2
[X,Y] = ndgrid(1:np,1:np);
all_perms = [X(:) Y(:)];
case 3
[X,Y,Z] = ndgrid(1:np,1:np,1:np);
all_perms = [X(:) Y(:) Z(:)];
otherwise
error("n > 3 not implemented")
end
probs = prod(reshape(p(all_perms), [], n), 2);
[probs_sorted, order] = sort(probs, 'descend');
most_prob = cumsum(probs_sorted) <= p_cut;
S = all_perms(order(most_prob), :);
end
Examples of correct output of this function:
>> S = most_probable_sequences([0.95 0.04 0.01], 1, 0.99)
S =
1
2
>> S = most_probable_sequences([0.01 0.04 0.95], 2, 0.99)
S =
3 3
3 2
2 3
3 1
Bill Tubbshttps://ch.mathworks.com/matlabcentral/profile/authors/4985015tag:ch.mathworks.com,2005:Question/4120922018-07-25T13:48:00Z2021-06-23T13:13:48ZHow can I overlay two images with different colormaps in App Designer?Good morning,
I would like to ask you if it is possible to overlay two (or more) images with different colormap in the figure of App Designer.
If I do not use App Designer, the following code:
figure1=figure;
ax1=axes('Parent',figure1);
ax2=axes('Parent',figure1);
set(ax1,'Visible,'off');
set(ax2,'Visible','off');
I=imshow(ImageB,[],'Parent',ax2);
set(I, 'AlphaData',(ImageB>threshold).*alphaValue);
colormap(ax2,colormapValue)
imshow(ImageA,[],'Parent',ax1)
works finely. However I am not able to "translate" it in App Designer.
Is this possible in App Designer?
Thanks so much
Martina Stellahttps://ch.mathworks.com/matlabcentral/profile/authors/6268968tag:ch.mathworks.com,2005:Question/3869362018-03-07T18:44:27Z2021-06-23T13:11:45Zchange x,y,z axes position in a 3d plot graph Good Evening,
I need to change position of axes in a 3d graph.
I tried to do that using graph properties but it does not work, Matlab has this option in 2D plot in axis properties window in the graph, but it does not work in 3d plots. I was wondering if there is a way to do it.
please find attached the graph i need to change its axes positions (arrows and text in red arethe new position I want the axes to be placed at).
the info from matlab documentation that says that this option works only in 2d plots is attahced as well.
Thanks a lot
Best regards,
HossamHossam Selimhttps://ch.mathworks.com/matlabcentral/profile/authors/1875530tag:ch.mathworks.com,2005:Question/8631402021-06-23T09:16:53Z2021-06-23T13:09:14ZHow to reduce the ALSA latency when deploying Matlab scripts on Raspberry ? I would like to have the lowest audio latency possible on Raspberry Pi when deploying a Matlab script. However, it seems that Matlab introduce 0.5 second of latency because of the buffer size. I would like to know how I can reduce that without simulink.
I saw here https://fr.mathworks.com/matlabcentral/answers/164113-high-latency-for-audio-use-on-a-raspberry-pi-using-simulink that my answer has beens partly answered, but I would like to have more details.
Thank you !Guilhem Schenahttps://ch.mathworks.com/matlabcentral/profile/authors/17927665tag:ch.mathworks.com,2005:Question/8633302021-06-23T13:09:01Z2021-06-23T13:09:01ZCould anyone help me how to train the neural network model for regression, clustering using the inputs and targets as specified.my inputs = 15×1 cell array
{2×1 double}
{2×1 double}
{2×1 double}
{2×1 double}
{2×1 double}
{2×2 double}
{2×2 double}
{2×2 double}
{2×2 double}
{2×2 double}
{2×3 double}
{2×3 double}
{2×3 double}
{2×3 double}
{2×3 double}
my targets =
1 0 0
1 0 0
1 0 0
1 0 0
1 0 0
1 1 0
1 2 0
2 1 0
2 1 0
1 2 0
1 2 2
2 1 1
1 3 2
1 1 2
2 2 1
I tried with the follwoing code
load inputs
load targets
inputSize = 2;
numHiddenUnits = 100;
numClasses = 3;
layers = [ ...
sequenceInputLayer(inputSize)
fullyConnectedLayer(3)
reluLayer
regressionLayer]
maxEpochs = 70;
miniBatchSize = 27;
options = trainingOptions('adam', ...
'ExecutionEnvironment','cpu', ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'GradientThreshold',1, ...
'Verbose',false, ...
'Plots','training-progress');
net = trainNetwork(inputs,targets,layers,options);
But it results in error .
Could anyone please help me to overcome it.jaah navihttps://ch.mathworks.com/matlabcentral/profile/authors/11695462tag:ch.mathworks.com,2005:Question/8633252021-06-23T13:09:01Z2021-06-23T13:09:01Zi can plot my chart, what should i do?Amron Rosyadahttps://ch.mathworks.com/matlabcentral/profile/authors/22899955tag:ch.mathworks.com,2005:Question/8614752021-06-21T13:26:42Z2021-06-23T13:08:53Z5G waveform generator app from the 5G toolbox matlab script export option does not workWhen running the 5G waveform app, and then selecting export--> export MATLAB script
gives an answer that
Exporting MATLAB script is not supported for downlink FRC-NR(5G) waveformsAmichai Sanderovichhttps://ch.mathworks.com/matlabcentral/profile/authors/7144641tag:ch.mathworks.com,2005:Question/8624552021-06-22T13:36:40Z2021-06-23T13:04:15Zhow to plot different cell arrays in just one graphic? Probably it could be a tricky question... however : having 2 different cell arrays, how can I plot the first cell (of the first array) and then the first cell (of the second array) consecutively and create a general plot in the same way for the other cells? , all together in a plot. Thanks.Fercho_Salahttps://ch.mathworks.com/matlabcentral/profile/authors/21300178tag:ch.mathworks.com,2005:Question/8632052021-06-23T10:11:51Z2021-06-23T12:58:22ZHow to modify the y-axis tick label and tick values (2016a)I have three variables day, time and z2 and i plot using imagesc. Below are the data information:
data information:
day 1*1420 double(each number is equal to 6 hours)
time 1*3001 double (this case has -300:300 with interval of 0.2)
z2 1420*3001 double
Later I converted the weeks segments into date by using below code.
fig=figure(ii);
h1=subplot(3,1,1);
imagesc(time,day,z2);
colormap(jet)
YTickStr = char(datetime('10/10/2018', 'InputFormat', 'dd/MM/yy', 'Format', 'dd/MM/yy') + hours(day*6));
set(gca, 'YTick', 1:lengday, 'YTickLabel', YTickStr);
xlim([-100 100]);
If i do not use any interval, ticks label are so difficult to read as below and I cant read any thing
Later, I change the interval with 1:500:lengday and it starts from 1JAN which i exected to start from 10/10/18.
How can I modify the code so that it gives me the interval based on Ytrickstr?
here is my failed attemt which gives me the first 5 values from YTickStr.
yval = ylim(gca);
set(gca,'YTick',linspace(yval(1),yval(2),5),'YTickLabel', YTickStr)
YTickStr files is like this
10/10/18
10/10/18
10/10/18
11/10/18
11/10/18
11/10/18
11/10/18
12/10/18
12/10/18
12/10/18
12/10/18
13/10/18
13/10/18
13/10/18
13/10/18
14/10/18
Thank you very muchAAhttps://ch.mathworks.com/matlabcentral/profile/authors/20389342tag:ch.mathworks.com,2005:Question/8345582021-05-19T21:39:30Z2021-06-23T12:57:57ZProblem during simulink subsystem export as pdf image.Hi guys, I'm trying to export a simulink subsystem as a pdf image. In this subsystem I've inserted an equation inside an annotation and then I've colored the background but when I export as a pdf image, by using the option "Print" (Ctrl+P), I obtain that the annotation is only partially colored:
How can I obtain a fully colored annotation?
Giuseppehttps://ch.mathworks.com/matlabcentral/profile/authors/9702519tag:ch.mathworks.com,2005:Question/8633202021-06-23T12:57:32Z2021-06-23T12:57:32ZHow can I vectorize a time dependent for loop correctly?Hello there,
currently I am working on my Bachelor thesis in theoretical physics and I am trying to simulate the direct laser acceleration of an electron in a plasma channel. Therefor I solved the differential equation of motion using the Boris-Pusher method, because the ode45 function leads to some unexpected numerical errors. So far so good. I would like to plot a color code of the maximum energy for two different initial parameters and . Unfortunately the result seems to be unusually high. Since the Boris-Pusher itself (line 42-63) seems to be working fine, the error has to be related to some wrong calculation of in line 65 and 66, according to my assumption. Ideally i want to calculate for every timestep in the given timespan and extract afterwards.
The expected image should look like the one in the attachment.
Maybe you can help me out with some advice. If I forget to mention important aspects, feel free to ask for more details.
Thanks in advance!Nico Boschhttps://ch.mathworks.com/matlabcentral/profile/authors/22421472tag:ch.mathworks.com,2005:Question/8624352021-06-22T13:13:31Z2021-06-23T12:57:25ZNeed to apply trapezoidal rule for double integration with an array by using the for loopz=(0:0.1:10);
F1= @(r1,r2)exp(-(r1.^2+r2.^2).*A).*exp(-i*B.*z.*(r1.^2+r2.^2)).*besseli(n,r1.*r2./(sig^2)).*r1.*r2;
I want to use trapezoidal numerical integration on the F1 for the variables r1 and r2 for which limits are 0 to 1, where z is a matrix. The direct command of integral2 cannot be applied due to the array function. I am stuck at first loop, where the error "Conversion to double from function handle is not possible" is showing. Please help. Thanks in advance.
for i=1:m
xi=i*h;
sumx(i)=@(r2)F1(xi);
i=i+1;
end
GAYTRI ARYAhttps://ch.mathworks.com/matlabcentral/profile/authors/22361763tag:ch.mathworks.com,2005:Question/8595202021-06-18T11:55:53Z2021-06-23T12:57:10ZUnexpected rounding of numbers by matlab??? Why it is happening? Dear Community,
can anyone explain me why Matlab rounding my data during assigning of the value(s) to a variable(s)????
Description:
My code started rounding values by himself during the data analysis, nevertheless that it was working nicely for months before. During execution the code I am extracting the data y_lim and ybin:
h=binscatter(x,y,250,'FaceAlpha',1);
h.ShowEmptyBins = 'off';
ax = gca;
ax.YScale="log";
ax.XLim=([-2 20]);
y_lim=h.YLimits
ybin=h.YBinEdges
the results presented in the WORKSPACE are obviously wrong: y_lim = [0, 1.005]
if in COMMAND Window i look on h handler properties, i see the correct data:
YLimits: [1.002305238077898e-06 1.002305238077898e+00]
ok... then I tried to access to my handler h in the command window and i got a correct result:
>> h.YLimits
ans = 1.002305238077898e-06 1.002305238077898e+00
Next step made me crazy. I assign the variable y lim using the same command like i used in the code and got CORRECT value:
>> y_lim=h.YLimits
y_lim =
1.002305238077898e-06 1.002305238077898e+00
CAN anyone help me with this issue??? Is this a matlab bug or i don't understand something.
Sergii Snegirhttps://ch.mathworks.com/matlabcentral/profile/authors/17570956tag:ch.mathworks.com,2005:Question/8630352021-06-23T06:32:54Z2021-06-23T12:54:24Znvcc fatal : Value 'c++17' is not defined for option 'std'Hello,
I'm would like to use some C++17 features in my library. The library is header only, and compiles with MSVC 15.19 v14.16 toolset and CUDA 11.3 that are installed on my machine. I wrap this library in a mex function which acts as an interface for inputs and outputs from and to Matlab, but having trouble compiling it.
I use the following command to compile:
mexcuda -v -R2018a '-LC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3\lib\x64' -lcublas ...
NVCC_FLAGS='-std=c++17 -Xcompiler=/std:c++17 --default-stream legacy'...
.\path\to\mex\file.cu
and get:
Error using mex
nvcc fatal : Value 'c++17' is not defined for option 'std'
In the nvcc_msvcpp2017.xml build configuration file I noticed that CUDA 10.1 is referenced. This version indeed does not support C++17 standard, but I find it bizzare that anything would compile at all seing as I do not have CUDA 10.1 installed on my system (unless it shipped with Matlab). I tried creating a custom .xml file to correct the versioning but that did not solve the issue, my guess though is that I need to adjust some environment variable, but I have no clue which one.
Thank for your help!Vyacheslav Samokhvalovhttps://ch.mathworks.com/matlabcentral/profile/authors/21912726tag:ch.mathworks.com,2005:Question/8633102021-06-23T04:00:00Z2021-06-23T12:49:16ZWhat does this strange error mean when I am trying to compiler my GUI as standalone application in MATLAB Compiler R2020b?My application only consists of .m files and .fig files.
The packaging works without issues but after that, I get the following error during the compilation:
File analysis was canceled because the following error occurred:
Import argument "internal.matlab.importtool.server.ImportUtils" in MATLAB code 'C:\Program Files (x86)\toolbox\matlab\datatools\importtool\matlab\peer\+internal\+matlab\+importtool\+peer\uiimportFile.m' cannot be found or cannot be imported.
And in an additional window:
Input was not a valid graphics object.
Error in = > my_gui.m at line 42
(The referenced line of code called the gui_mainfcn.)MathWorks Support Teamhttps://ch.mathworks.com/matlabcentral/profile/authors/4622813