https://in.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2020-09-29T04:44:27Ztag:in.mathworks.com,2005:Question/6017112020-09-29T04:44:27Z2020-09-29T04:44:27ZHow do I sort my data based on time series?It is a question, but when dealing with regression learning devices in the app, I do not know how "cross-validation" in the column of new session -> verification handles data.
The data entered is one year's time series data, such as temperature data measured every hour, separated from 20〇〇/month/day. Does "cross-validation" verify this data by dividing it into chronological order?
Or is it n-divided by collecting data completely randomly regardless of the date?
If it's the latter, I'd like you to tell me how to divide the data based on time series.孝太郎 泉https://in.mathworks.com/matlabcentral/profile/authors/19125077tag:in.mathworks.com,2005:Question/6016902020-09-29T03:42:10Z2020-09-29T04:42:28Zsolution of 3d nonlinear equationx_p, y_p, z_p=(4, 5, 2)
x_1, y_1, z_1=(8, 9, 5)
x_2, y_2, z_2=(2, 5, 1)
x_3, y_3, z_3=(6, 1, 3)
t_1=5.692820*10^-9
t_2=-2.924173*10^-9
t_3=-12.010097*10^-9
c=3.0*10^8
and my three equations are
eqn1 = sqrt((x(s)-x_p)^2+(y(s)-y_p)^2+(z(s)-z_p)^2)-sqrt((x(s)-x_1)^2+(y(s)-y_1)^2+(z(s)-z_2)^2)-(c*t_1)
eqn2 = sqrt((x(s)-x_p)^2+(y(s)-y_p)^2+(z(s)-z_p)^2)-sqrt((x(s)-x_2)^2+(y(s)-y_2)^2+(z(s)-z_2)^2)-(c*t_1)
eqn3 = sqrt((x(s)-x_p)^2+(y(s)-y_p)^2+(z(s)-z_p)^2)-sqrt((x(s)-x_3)^2+(y(s)-y_3)^2+(z(s)-z_3)^2)-(c*t_1)
where only x(s), y(s), z(s) are unknown are rest all are known
BEST REGARDSali hassanhttps://in.mathworks.com/matlabcentral/profile/authors/17127843tag:in.mathworks.com,2005:Question/4782712019-08-30T13:48:40Z2020-09-29T04:40:37Znonlinear model in simulink and designing pid controllerHi guys
when I design for a nonlinear model in simulink a pid controller, and I want to run the simulink, it gives me bellow image.
(max step size is 0.2s , please go to configuration parameter and set "automatic solver parametric selection" to "none". although, I do that again it gives me this warning and when I see the scop, it does not give me a good result, it gives me just 0 in output instead of giving 2 things( output and input).
I attach also my slx file.
azam ghamarihttps://in.mathworks.com/matlabcentral/profile/authors/12677969tag:in.mathworks.com,2005:Question/6017052020-09-29T04:38:13Z2020-09-29T04:38:13Z I want to model 100KVA load operating at 0.9 power factor lagging. What should i set Active Power, QL and QC in load parameters?Hi,
Please help me find the answer to this question:
I want to model 100KVA load operating at 0.9 power factor lagging. What should i set Active Power, QL and QC in load parameters?Syed Umaid Alihttps://in.mathworks.com/matlabcentral/profile/authors/19147964tag:in.mathworks.com,2005:Question/990672013-03-05T15:36:00Z2020-09-29T04:37:09ZWhy do I receive License Manager Error -9?When I try to launch MATLAB, I get the following error:
ERROR: License checkout failed. Invalid host. License Manager Error -9
MathWorks Support Teamhttps://in.mathworks.com/matlabcentral/profile/authors/4622813tag:in.mathworks.com,2005:Question/6000912020-09-25T21:14:45Z2020-09-29T04:36:55ZWhat is the parameter minimum performance gradient (trainParam.min_grad) of traingd?I use the training function "traingd" to train a shallow neural network:
trainedNet = train(net,X,T)
For the training function "traingd": How is the parameter minimum performance gradient (net.trainParam.min_grad) defined?
As the gradient for the gradient descent is usually a vector, but net.trainParam.min_grad is a scalar value, I am confused.
Is it the change in the performace (loss) between 2 iterations, and if yes: Does it refer to the training, validation or testing errror?
Thanks in advance!
I use MATLAB 2013 and 2015 with the neural network toolbox.AntonyHhttps://in.mathworks.com/matlabcentral/profile/authors/3941968tag:in.mathworks.com,2005:Question/6003672020-09-26T14:46:16Z2020-09-29T04:35:59ZPassing parameters to dde23 slows it downI am having a set of Delay Differential Equations which I am trying to solve using dde23. When I define the function in the form,
function change = eqn(t, X, Z)
%Defining parameter 'k' here
%Inserting the set of equations here.
end
, the code runs.
However if I try to pass a parameter into the function
function change = eqn(t, X, Z, k)
%Inserting the set of equations here.
end
And accordingly modify dde23 line in the main code:
K = 1;
sol = dde23(@(t, x, z) eqn(t, x, z, K), tau, init_vals, tspan, options);
The code takes a lot of time to run. If anyone knows why and how I can improve this, please let me know!
I have to be able to pass the parameter to the function since I am going to use dde23 in a loop with a range of the parameter values. Sneha Srikanthhttps://in.mathworks.com/matlabcentral/profile/authors/15758357tag:in.mathworks.com,2005:Question/6014352020-09-28T17:39:03Z2020-09-29T04:35:51ZWhy does this error happen? [�Warning: Rank deficient, rank = 2, tol = 1.850312e-14.]� Why does this error happen?
A = [1 2 3; 4 5 6; 7 8 9; 10 11 12]
A =
1 2 3
4 5 6
7 8 9
10 11 12
A/A
[�Warning: Rank deficient, rank = 2, tol = 1.696862e-14.]�
ans =
1.0000 0 0 0
0.6667 0 0 0.3333
0.3333 0 0 0.6667
0.0000 0 0 1.0000Isabel Muñizhttps://in.mathworks.com/matlabcentral/profile/authors/19704174tag:in.mathworks.com,2005:Question/6013632020-09-28T15:21:00Z2020-09-29T04:35:37ZRotate Spherical Coordinates to find new Vector MagnitudeDear Forum,
I am given a ,,. Does Matlab have a function to convert and find the from a new ?Chadhttps://in.mathworks.com/matlabcentral/profile/authors/2205100tag:in.mathworks.com,2005:Question/6017022020-09-29T04:34:37Z2020-09-29T04:34:37ZBit Error Rate (BER) BPSK - Bit error probability (Pb) BPSKHello guys
I made a code and plotted the BER curve. Could anyone help me?
I don't know if I plotted the right graph or if I have some wrong information.
Depending on the parameter that I change the graph is very strange.
Could someone give me an idea?
Follow the code below:
clear; close all; clc; tic;
% BPSK
M = 2;
% número de bits ou símbolos
N = 100;
% Gera bits aleatórios ( matriz de variaveis binarias)
Bits_ale = randi([0 M-1],1,N);
% Modulação BPSK 0 -> -1; 1 -> 1
Bits_bpsk = 2 * Bits_ale-1;
% Gera bits de marca d'água aleatórios
Bit_wat = randi([0 M-1],1,N);
Theta = 180/4; % (pi/4)
for k = 1:N
if Bit_wat(k)==1
Bit_enviado(k) = Bits_bpsk(k) * exp(1i * Bits_bpsk(k) * Theta);
else
Bit_enviado(k) = Bits_bpsk(k) * exp(-1i * Bits_bpsk(k) * Theta);
end
end
%generating noise with zero mean and var. equal to 1.
noise=1/sqrt(2)*(randn(1,N)+1i*randn(1,N));
mean(abs(noise.^2)) %test the power of the noise
SNR=0:9; %set SNR in dB
snr_lin=10.^(SNR/10); %calculate linear snr from dB SNR.
y=zeros(length(SNR),N);
%multiply sqrt of snr to signal and add noise:
for i=1:length(SNR)
y(i,:)=real(sqrt(snr_lin(i))*Bit_enviado+noise);
end
%reciever and ber count
err=zeros(length(SNR),N);
Err=zeros(10,2);
for i=1:length(SNR)
for j=1:N
if y(i,j)>=0
y(i,j)=1;
else
y(i,j)=0;
end
end
err(i,:)=abs(y(i,:)- Bits_ale);
Err(i,:)=size(find(err(i,:)));
end
%calculating BER
ber=zeros(length(SNR),1);
for i=1:length(SNR)
ber(i)=Err(i,2)/N;
end
%theoretical BER calculation
theoryBer = 0.5*erfc(sqrt(snr_lin));
semilogy(SNR,ber,'b*-','linewidth',1);
grid on;
hold on;
semilogy(SNR,theoryBer,'r+-','linewidth',1);
grid on;
xlabel('Eb/N0');
ylabel('BER');
legend('Simulation','Theory') ;
toc;
adriane duartehttps://in.mathworks.com/matlabcentral/profile/authors/10945340tag:in.mathworks.com,2005:Question/5975292020-09-21T21:47:54Z2020-09-29T04:29:13ZIs it possible to add a custom tab to the Simulink toolstrip ?Hello,
I would like to know if users are allowed to add a tab to the Simullink toolstrip. In the latest versions of Matlab, classic menu functions are being migrated to the new Simulink toolstrip. I have a custom rolling menu filled with custom functions and would like to migrate its funcitons to a custom tab. Some Add-on/Apps can already do so :
Are users allowed to do the same ?P Lepagehttps://in.mathworks.com/matlabcentral/profile/authors/19608904tag:in.mathworks.com,2005:Question/6016992020-09-29T04:25:54Z2020-09-29T04:25:54ZWhat is single scale fusion in digital image processingHi all..can anyone explain me about single scale fusion with some examples..your help is really appreciated.Rockyhttps://in.mathworks.com/matlabcentral/profile/authors/16943049tag:in.mathworks.com,2005:Question/6016962020-09-29T04:01:33Z2020-09-29T04:24:52ZOutput argument "T" (and maybe others) not assigned during call to "StdAtm".The first loop works and I don't know why T, rho, and P are not defined when I call the volume_function(4, 0.5).
function [t, h, V] = volume_function(m, dt)
h = 0;
hmax = 51000;
w = 0;
t = 0;
[T, ~, P] = StdAtm(h);
volume = [];
Vmax = 5000;
V = (m.*4124.*T)./(P);
volume = [volume, V];
time = [];
height = [];
height = [height, h];
while h <= hmax || V < Vmax
[T, rho, P] = StdAtm(h);
V = (m.*4124.*T)./(P);
R = (((3./4).*V)./(pi)).^(1./3);
volume = [volume, V];
mu = 0.000017890.*((T/288.15).^(1.5)).*((288.15+110.4)./(T+110.4));
Re = (rho.*w.*(2.*R))./(mu);
Cd = ((24)./(1+Re))+((6)./(1+sqrt(Re)))+0.1;
D = 0.5.*rho.*(w.^2).*pi.*(R.^2).*Cd;
W = (m+40).*9.81;
rho_H = (P)./(4124.*T);
B = (4./3).*pi*(R.^3)*(rho-rho_H).*9.81;
Fnet = B - D - W;
a = Fnet./(m+40);
w = w + a.*dt;
h = h + w.*dt;
height = [height, h];
t = t + dt;
time = [time, t];
end
end
function [T, rho, P] = StdAtm(h)
if h >= 0 && h < 11000
lapse = -0.0065;
T0 = 288.15;
P0 = 101325;
h0 = 0;
T = T0 + (lapse.*h);
if lapse ~= 0
P = P0 .* ((T0)/(T0 + lapse.*(h - h0))).^((9.81.* 0.02896)./(8.314.*lapse));
else
P = P0 .* exp((-9.81.* 0.02896.*(h-h0))./(8.314.*T0));
end
rho = P0./(8.314.*T0);
elseif h >= 11000 && h < 20000
lapse = 0;
T0 = 216.65;
P0 = 22632.1;
h0 = 11000;
T = T0 + (lapse.*h);
if lapse ~= 0
P = P0 .* ((T0)/(T0 + lapse.*(h - h0))).^((9.81.* 0.02896)./(8.314.*lapse));
else
P = P0 .* exp((-9.81.* 0.02896.*(h-h0))./(8.314.*T0));
end
rho = P0./(8.314.*T0);
elseif h >= 20000 && h < 32000
lapse = 0.001;
T0 = 216.65;
P0 = 5474.89;
h0 = 20000;
T = T0 + (lapse.*h);
if lapse ~= 0
P = P0 .* ((T0)/(T0 + lapse.*(h - h0))).^((9.81.* 0.02896)./(8.314.*lapse));
else
P = P0 .* exp((-9.81.* 0.02896.*(h-h0))./(8.314.*T0));
end
rho = P0./(8.314.*T0);
elseif h >= 32000 && h < 47000
lapse = 0.0028;
T0 = 228.65;
P0 = 868.019;
h0 = 32000;
T = T0 + (lapse.*h);
if lapse ~= 0
P = P0 .* ((T0)/(T0 + lapse.*(h - h0))).^((9.81.* 0.02896)./(8.314.*lapse));
else
P = P0 .* exp((-9.81.* 0.02896.*(h-h0))./(8.314.*T0));
end
rho = P0./(8.314.*T0);
elseif h >= 47000 && h <= 51000
lapse = 0;
T0 = 270.65;
P0 = 110.906;
h0 = 47000;
T = T0 + (lapse.*h);
if lapse ~= 0
P = P0 .* ((T0)/(T0 + lapse.*(h - h0))).^((9.81.* 0.02896)./(8.314.*lapse));
else
P = P0 .* exp((-9.81.* 0.02896.*(h-h0))./(8.314.*T0));
end
rho = P0./(8.314.*T0);
end
endRobert DeLonghttps://in.mathworks.com/matlabcentral/profile/authors/19416452tag:in.mathworks.com,2005:Question/6015822020-09-28T21:52:05Z2020-09-29T04:20:58Z Pareto Front of the multi-objective problemFor Pareto Front of the multi-objective problem, we can only get the final 'optimal value curve' of the objective functions, so how can we get all the original objective values and therefore we can see the front clearly and also see all other resultsZonghong Huhttps://in.mathworks.com/matlabcentral/profile/authors/17609182tag:in.mathworks.com,2005:Question/6016572020-09-29T02:35:36Z2020-09-29T04:20:54ZUnable to open openExample('nav/GenerateAlternativeTrajectoriesForReferencePathExample')I am unable to use the command referencePathFrenet. i get the following message ->Unrecognized function or variable 'referencePathFrenet'.
Also I am unable to open the example openExample('nav/GenerateAlternativeTrajectoriesForReferencePathExample').
I am using MATLAB 2020a.
Can anybody please guide me on this?Sai Kamal Sree Veepurihttps://in.mathworks.com/matlabcentral/profile/authors/7460587tag:in.mathworks.com,2005:Question/5995992020-09-25T06:12:54Z2020-09-29T04:17:29ZHow to pick the values from individual grids ?Hi everyone,
May someone help me here ,,
My data set is consists of three paramateres ... x, y and z ..
the x, y paramteres are grided at an interval of 0.005, This give me a matrix of 16 by 16 grid ..
In each grid z-values are placed. Now I want to calculate the the z vales in each grid ...
The figure show the pictorial representation of data in each grid ... My task is to generate an output file with 256 columns and each colum give us the values of point placed in each grid ..
Thank you
clear all
%clc
a=xlsread('data');
x=a(:,1);% x parameter
y=a(:,2); %y parameter
z=a(:,3); % z parameter
%Grid scale
x2=-130.04:0.005:-129.96;
y2=45.91:0.005:45.99;
aahttps://in.mathworks.com/matlabcentral/profile/authors/19179225tag:in.mathworks.com,2005:Question/6015942020-09-28T21:59:50Z2020-09-29T04:15:46ZMove colorbar location to the east in tiled layout figureI have a fugure that looks horrible due to the colorbar overlaying the tiledlayout.
Any ideas on how to move the colorbar to the east so it's outside of the figure?
Thanks.
Eric Escotohttps://in.mathworks.com/matlabcentral/profile/authors/7056746tag:in.mathworks.com,2005:Question/6016632020-09-29T02:48:06Z2020-09-29T04:04:34ZFind indicies of k smallest matrix elementsI'm trying to find the indicies of smallest k matrix elements.
For example if I have
A = [10 5 2; 34 5 21; 4 6 8];
and I want to find the smallest 2 elements indicies then I want indicies 7 and 3.Brady Deanhttps://in.mathworks.com/matlabcentral/profile/authors/19508117tag:in.mathworks.com,2005:Question/3349702017-04-12T08:38:06Z2020-09-29T03:57:47ZHow can I solve this error?I'm trying to simulate a mppt for PV system using fuzzy logic controller, but I get this error:
Error evaluating parameter 'fismatrix' in 'PVFuzyy/Fuzzy Logic Controller with Ruleviewer'
Caused by:
Undefined function or variable 'MyFis'.
the fis file is defined correctly and can be analysed in fuzzy inference system. Fis file and the simulink file are in the same folder and I did everything that came to my mind but still couldn't solve the error. Please help on this matter.
Thank you very much in advance.
Mohammad Mirloohttps://in.mathworks.com/matlabcentral/profile/authors/8209176tag:in.mathworks.com,2005:Question/6016692020-09-29T02:51:00Z2020-09-29T03:49:35ZConverting CSV files to xlsm excel worksheetHi
I have a folder containing many excel files ( more than 300) in csv format . I need to write all these files in xlsm excel work sheet.
Can this be done in matlab . Can anyone please help.
below, i have attach how the converting looks like.
thank you very muchnaouras salehhttps://in.mathworks.com/matlabcentral/profile/authors/14021404tag:in.mathworks.com,2005:Question/6016842020-09-29T03:29:02Z2020-09-29T03:45:48ZFunction with two outputs only giving one outputfunction [C K] = FTOCK (degreeF)
%FTOCK converts degrees reading in farenheit to celcius and then kelvin
degreeF;
C=(degreeF-32)/1.8;
K=(degreeF+459.67)/1.8;
%fprintf('%.1f degrees in Farenheit Translates to %.2f degrees Celcius and %.2f degrees Kelvin\n',degreeF,C,K);
end
I do not know why this only outputs the calculated Celsius degree, K is clearly within the brackets. Brian Wellshttps://in.mathworks.com/matlabcentral/profile/authors/16445935tag:in.mathworks.com,2005:Question/6016872020-09-29T03:31:41Z2020-09-29T03:38:37Z When I run the file I get an error
Hello when I run the following code, I get an error of
Error using plot
Vectors must be the same length.
Error in convolution (line 8) plot (t, f_pulse);
Can you help me please Thank you
t=-pi:0.01:pi;
f_pulso=[zeros(1,1000*3.14+1),ones(1,1000*3.14+1),zeros(1,1000*3.14+1)];
a=2*pi;
b=cos(a*50*t);
f_conv=conv(f,f_pulso);
figure(1);
subplot(3,1,1);
plot(t,f_pulso);
title('Señal Pulso');
xlabel('Tiempo(t)');ylabel('e(t)');
subplot(3,1,2);
plot(t,b);
title('cos(2.pi.t)');
xlabel('Tiempo(t)');ylabel('cos(2*pi*100*t)');
%Convolucion
f_conv=conv(f,f_pulso);
subplot(3,1,3);
plot(t,f_conv(l:length(f)),'r')
title('Convolucion');
xlabel('Tiempo(t)');Hernan Reyeshttps://in.mathworks.com/matlabcentral/profile/authors/19367318tag:in.mathworks.com,2005:Question/5820052020-08-20T06:03:51Z2020-09-29T03:31:35ZCan I add a file path for a document that is not on my desktop using the SPM12 program in MatLab?I am wishing to change the file path of items in the batch of items I am using to conduct a fMRI analysis and would like to know if its possible to change the file path without having the items or documents saved on my desktop? If I had the file paths I needed in say a word document am I able to feed these paths into the batch editor? So instead of selecting the 'Edit' menu and the 'Add item' and then navigating to the document on my desktop I wish to add, could I add a file path that matches the location of the file on my colleague's desktop?
Thanks!
Kate Ridgwayhttps://in.mathworks.com/matlabcentral/profile/authors/19239902tag:in.mathworks.com,2005:Question/6009462020-09-28T00:30:28Z2020-09-29T03:27:35Zsimple problem with double integral, why give me an error?hello, I should solve a double integral in which the integrand function contains parameters that I must subsequently obtain through a minimization.
f=
the code I wrote is the following:
clc
clear all
x0=[1 1 1 1 1 1]
lb=[0.01 0.01 0.01 0.01 0.01 0.01]
ub=[5 5 5 5 5 5 ]
ftomin=@(x) provaInt(x(1),x(2),x(3),x(4),x(5),x(6))
options = optimoptions('simulannealbnd','FunctionTolerance', 1e-6,'MaxIterations',500,'MaxFunEvals',500,'PlotFcns',{@saplotbestx,@saplotbestf,@saplotx,@saplotf,@saplottemperature,@saplotstopping});
[x,fval,exitflag,output]=simulannealbnd(ftomin,x0,lb,ub,options)
function f=provaInt(St,at,bt,am,bm,Sm)
syms t m
fi=((1./(St.*(t-3)*sqrt(2*pi))).*exp((-1/2).*((log(t-3)-at-bt*3)./St).^2)).*((1/(sqrt(2*pi)*Sm)).*exp((-1/2).*((m-am-bm*4)./(Sm)).^2)));
f=int(int(fi,t,1970,1980),m,5.75,8));
%where all parameters to be found are positive and real (not imaginary numbers)
%f=-(2535301200456458802993406410752*pi*(erf((2^(1/2)*(1/Sm^2)^(1/2)*(am + 4*bm - 8))/2) - erf((2^(1/2)*(1/Sm^2)^(1/2)*(am + 4*bm - 23/4))/2))*(erfi((2^(1/2)*(-1/St^2)^(1/2)*(at + 3*bt - log(1967)))/2) - erfi((2^(1/2)*(-1/St^2)^(1/2)*(at + 3*bt - log(1977)))/2)))/(31859534503965572279823959492121*Sm*St*(1/Sm^2)^(1/2)*(-1/St^2)^(1/2))
end
All the parameters to be obtained with the optimization are positive and real (no imaginary numbers).
If I supply the integral with the "int" function (as in the example) matlab gives me the following error:
Conversion to logical from sym is not possible.
Error in acceptancesa (line 31)
if delE < 0
Error in sanewpoint (line 30)
if options.AcceptanceFcn(optimvalues,newx,newfval)
Error in saengine (line 29)
solverData = sanewpoint(solverData,problem,options);
Error in simulanneal (line 50)
solverData = saengine(solverData,problem,options);
Error in simulannealbnd (line 163)
[x, fval, exitflag, output] = simulanneal(FUN, x0, [], [], [], [], lb, ub, options);
Error in prova_funzione_integrale (line 11)
[x,fval,exitflag,output]=simulannealbnd(ftomin,x0,lb,ub,options)
Caused by:
Failure in AnnealingFcn evaluation.
If, on the other hand, I supply the integral already resolved ("f" commented in green) the optimization takes place without problems.
In reality I have to solve a quadruple integral in which the extremes of integration are defined and are numbers. However, to better understand how to do this type of calculations I tried with a double integral with a part of the function that I have to solve.
What am I doing wrong?
Thank you very much for helping.Emanuele Biondinihttps://in.mathworks.com/matlabcentral/profile/authors/9377243tag:in.mathworks.com,2005:Question/6016722020-09-29T02:56:43Z2020-09-29T03:19:37ZDoes anyone know of a function that will take timeseries data and find 12-hour averages throughout (day and night averages)? I have a 17 day timeseries and I would like to calculate 12-hour averages for the data so that I end up with daytime averages and nighttime averages. In this case "day" will be approx 06:00 to 18:00 (12 hours) and night is 18:00 to 06:00 (12 hours). I'm not sure if a function already exists to do this given timestamps and the data vector in question. If not would I want to loop through each 12 hour period? The night data might be problematic since it spans 2 dates. Anyway, I'm thrilled to hear any ideas/advice. I've attached my timestamps (MX) and example data (PH). Timestamps are in matlab time (serial date number from July 23, 2017 to August 9, 2017). Thank you!
Heidi Hirshhttps://in.mathworks.com/matlabcentral/profile/authors/6143971tag:in.mathworks.com,2005:Question/6016392020-09-29T00:48:12Z2020-09-29T03:18:40ZFrustrating matlab is.5x2matrix=[2 4;7 9;12 14;17 19;22 24]
x=[2;7;12;17;22]
y=[4;9;14;19;24]
% output equation: w=(10x^2)-13xy-(3y^2)
Problem: Using the values in the first column of the 5x2 matrix for x and the values in the second column of the 5x2 matrix for y. The output table should display x in the first column, y in the second column, and w in the third column.
I need help with how to assign the output equation to w using the 5x2matrix for the x and y values, and idk how to put all that info into one table. Thanks. Benjamin Johnstonhttps://in.mathworks.com/matlabcentral/profile/authors/19508881tag:in.mathworks.com,2005:Question/6011502020-09-28T09:19:53Z2020-09-29T03:17:48Zprediction of remaining useful lifeI am doing my coding to predict the remaining useful life of the battery. I am taking NASA dataset for the predicition. Furthermore i am using charge volatge, current , temperature and capacity as input and target value to be capacity. The problem lies in the prediction of data from a particular set point on x axix. How can we predict the result from a particular point .Shaheer Ansarihttps://in.mathworks.com/matlabcentral/profile/authors/17685924tag:in.mathworks.com,2005:Question/6016602020-09-29T02:44:02Z2020-09-29T03:11:43Zmex, error C3861: "mxGetDoubles": Cannot find the identifier, "mxGetUint8s": Cannot find the identifier ？When I write the .cpp file and want to generate the .mexw64 library file, I use the mex function to compile, and an error C3861: "mxGetDoubles": identifier not found, "mxGetUint8s": identifier not found, but I can use the "mxGetPr" function to compile .cpp files for normal mex. I am using MATLAB2020b version. According to the help document, the official recommendation is to use mxGetDoubles or mxGetUint8s function instead of mxGetPr function. When I use the mxGetUint8s function to get the output *plhs[] data pointer, the compiler reported the above error, and I found the definition of mxGetUint8s in "matrix.h", and it has been included correctly. Why can't I find the identifier?
#include "mex.h"
#include "matrix.h"
#include "opencv2/opencv.hpp"
...Omit code
mxUint8 *temp,*temp2
temp = (mxUint8*)mxGetUint8s(plhs[0]); // error C3861: "mxGetUint8s": Cannot find the identifier. or "mxGetDoubles" ,use "mxGetPr" instead is OK!
temp2 = (mxUint8*)mxGetUint8s(plhs[1]);
...Omit code
My computer configuration environment:
os: win10
ide: visual studio 2015 professional
matlab: matlab2020b, or matlab2020a
However, compiling and running the code in vs2015 is ok.cuihttps://in.mathworks.com/matlabcentral/profile/authors/3388605tag:in.mathworks.com,2005:Question/5987022020-09-23T19:23:42Z2020-09-29T03:10:46ZUnable to perform assignment because the left and right sides have a different number of elements.I dont know what is the issue in this code,
q = 1.6e-19;
E = [-0.5:0.001:0.5]; % [eV]
V = [0:0.001:0.5]; % [V]
mu = 0; % [eV]
kB = 1.38e-23; % [J/K]
kB = kB/q; % [eV/K]
h = 6.626e-34/(44/7); % [J.s]
h = h/q; % [eV.s]
const = (2*q)/h; % [C/eV.s]
T = 300; % [K]
g1 = 0.2; % [eV], gamma1
g2 = 0.2; % [eV], gamma2
g = 0.1;
dE = 0.001; % [eV], delta E
D = zeros(1,length(E));
for i = 1:length(E)
if E(i) >= -0.1
D(i) = 0.5;
else
D(i) = 0;
end
end
mu1 = zeros(1,length(V));
mu2 = zeros(1,length(V));
f1 = zeros(1,length(V));
f2 = zeros(1,length(V));
f = zeros(1,length(V));
F = zeros(1,length(V));
I = zeros(1,length(V));
for i = 1:length(V)
mu1(i) = mu + (q*V(i))/2;
mu2(i) = mu - (q*V(i))/2;
f1(i) = 1 ./ (1+exp((E-mu1(i))/(kB*T)));
f2(i) = 1 ./ (1+exp((E-mu2(i))/(kB*T)));
f(i) = f1(i)-f2(i);
F(i) = D(i)*g*f(i)*dE;
I(i) = const*sum(F(i));
end
disp(I);Gautam Khannahttps://in.mathworks.com/matlabcentral/profile/authors/17729779tag:in.mathworks.com,2005:Question/6016782020-09-29T03:10:27Z2020-09-29T03:10:27ZWhy does my import into EEGLab contain no eventsHi All,
I have exported an EDF file from BioTrace (a piece of software used to record EEG signals; EDF), and when I attempt to import it into MatLab's EEgLab, it says that there are no event markers (i.e. Events: none). I'm unfamiliar with MatLab, so I'm not sure if the issue is with the file, or just an issue with the user (me).
The example file that I'm using can be found here
Any help would be greatly appreciated
Thanksshannon bosshardhttps://in.mathworks.com/matlabcentral/profile/authors/17616439tag:in.mathworks.com,2005:Question/3288802017-03-09T03:16:30Z2020-09-29T03:04:36Zhow many for loops would be needed to loop through each value of two dimensional arrayGiven a two dimensional array, how many for loops would be
needed to loop through each value separately?
I am new to matlab and for loops and don't understand this question. I would appreciate your help, thank you.Greg Bensonhttps://in.mathworks.com/matlabcentral/profile/authors/9894829tag:in.mathworks.com,2005:Question/6015852020-09-28T21:52:19Z2020-09-29T02:51:58ZHow can I improve this really slow code, which consists of several nested for loops?Hi,
So I've written these nested for loops, but it takes a very long time to execute this code:
for T = linspace( 1, 5, 10 )
for xdot_0 = linspace( -3, 3, 10 )
for ydot_0 = linspace( 16, 20, 10 )
for thetadot_0 = linspace( -5, 0, 10 )
z = DifferenceMap( xdot_0, ydot_0, thetadot_0, T );
if norm(z) < 1e-3
disp( xdot_0, ydot_0, thetadot_0, T )
disp( z )
end
end
end
end
end
The DifferenceMap( ) function calls another function that gives solutions from the ode45 solver at final time, T.
Is there a better way to write this code so that it's faster?
Thanks,Noobhttps://in.mathworks.com/matlabcentral/profile/authors/6426532tag:in.mathworks.com,2005:Question/6015072020-09-28T19:47:45Z2020-09-29T02:43:00Zmatlab fprintf error? please helpHi all,
I am very very new to matlab, and I am trying to run a script that will read my txt files and write it on my xlsx file. I have about 120 txt files, so I am trying to run a script on them, but I keep having this fprintf error on a part of my script.
fid = fopen(sprintf('%s/Timeseries.ROIs/%s_timeseries.xlsx',rootdir,rois{roi}),'w');
colhdrs = {'Subject','Group','Gender','Subject','Condition','-4.4', '-2.2', '0', '2.2', '4.4', '6.6', '8.8', '11', '12.2'};
fprintf(fid,'%s\t',colhdrs{:}); fprintf(fid,'\n');
I keep facing an error with the script line below.
frpintf(fid, '%s \ t', colhdrs {:});
saying that it has Invalid file identifier. Use fopen to generate a valid file identifier.
Again, I am very new so any help would be much appreciated. Thank you so much! Sojung Younhttps://in.mathworks.com/matlabcentral/profile/authors/16315590tag:in.mathworks.com,2005:Question/6016512020-09-29T01:47:26Z2020-09-29T02:39:54ZAppending to cell arrayI have a 294x1 cell array. Some cells are 1x1 cells, the rest are 1x2 cells (please see attached pictures). I need to do the following things:
1) I need to append a label to the 1x1 cells. For example:
NewLabel2{1,2}(2) = "MyMissingLabel"
2) After doing the task in 1, all the cells will be 1x2 . Then, I need to extract the information from the second component of the cells and store it as as normal matrix. For example:
for i = 1:length(NewLabel2):
MyNewVariable(i) = NewLabel{i,1}(2)
end
Now, when I try to do the first one, I get the error "Convert to cell from char is not possible"
Can anyone point me in the right direction?
Thanks,
Picture 1:
Jose Rubiohttps://in.mathworks.com/matlabcentral/profile/authors/13245619tag:in.mathworks.com,2005:Question/5986242020-09-23T16:09:33Z2020-09-29T02:36:29ZTime series training using 2D CNN Hi ,
I am trying to use 2D CNN to train and then predict time series (specifically analog signal splitted into 5 samples each sequence ---> the whole input matrix is Nx5) ...
Though i defined 4d matrices XTrain and YTrain for trainNetwork() function as follows :
... COMMENTS ...
I defently defined 4d matrix with images 1xchannel_length but still getting the error below :
"
>> MatlabNnPilot
155 net = trainNetwork(XTrain,YTrain,layers,options);
Error using trainNetwork (line 165)
Invalid training data. X must be a 4-D array of images.
Error in MatlabNnPilot (line 155)
net = trainNetwork(XTrain,YTrain,layers,options);
"
Please advise how to resovle it if possible ?
Igor
igor Lisogurskyhttps://in.mathworks.com/matlabcentral/profile/authors/17781051tag:in.mathworks.com,2005:Question/6016242020-09-29T00:25:54Z2020-09-29T02:36:25ZHow to solve the Gompertz EquationHi all,
I am trying to run a simple gompertz equation. however when I run the code below only one line generates instead of two. Anyone have any ideas how to fix this?
%Gompertz Equation
% Parameter and intial condtions
r= (0.349)
p= [2.913 3.929 5.308 7.239 9.638 12.866 17.069 23.191]';
k= 451.7
% Time interval
t = (1790:10:1860)';
%Gompertz Equation
E= k.*(p/k).^exp(-r*t);
% Time Interval
a=(1790:10:1860)';
% Population
b= [3.929 5.308 7.239 9.638 12.866 17.069 23.191 31.443]';
% Plot
plot (a,b,'bo');
hold on
plot(t,E,'r');
line_color=['r'];
hold off
legend('Gompertz Model','Census Data');
axis([1790 1860 0 50]);
title('US Population Data');
ylabel('Population (Millions)');
xlabel ('Years');Kailin Johnssonhttps://in.mathworks.com/matlabcentral/profile/authors/18891789tag:in.mathworks.com,2005:Question/6013272020-09-28T14:41:08Z2020-09-29T02:35:25ZWants to input an rgb image and get the classified image as an rbg instead of greyscaleI am new to Matlab and I am finding it difficult to input a color image and give the classified output as color image. Instead I am only able to do for greyscale image. I have done the code for greyscale image. Please help me out. Can someone help me with the code to output as coloured image rather than a grayscale image. I have attached my code as well.renit anthonyhttps://in.mathworks.com/matlabcentral/profile/authors/16962317tag:in.mathworks.com,2005:Question/6016542020-09-29T02:33:04Z2020-09-29T02:33:04ZHow can I convert multiple mat files in one csv file for my dataset, or can create datasource for further processing with feature extraction method. There are 2 matrices. testCase fields are shown and another is IAT i.e. continuous time series data. Ritu Dahiyahttps://in.mathworks.com/matlabcentral/profile/authors/19096611tag:in.mathworks.com,2005:Question/6015012020-09-28T19:39:08Z2020-09-29T02:24:30ZHow to plot like this ? I found an image from statista. I’d like to plot like that in matlab is it possible ? Jeevan Kumar Bodaballahttps://in.mathworks.com/matlabcentral/profile/authors/13971181tag:in.mathworks.com,2005:Question/5999712020-09-25T17:09:16Z2020-09-29T02:22:42ZHow can I debug this?clc;clear
C1 = input('Please enter a code to break: ' , 's');
if length(C1) ~= 6
disp('Decoy message: Not a six-digit number.');
else
A = mod(sum(C1 - '0'),2);
if A == 1
disp('Decoy message: Sum is odd.')
else
C2 = (C1(1) - '0') * (C1(2) - '0') - (C1(3) - '0');
failed = false;
switch C2
case 1
Day = 'Rescue on Monday';
case 2
Day = 'Rescue on Tuesday';
case 3
Day = 'Rescue on Wednesday';
case 4
Day = 'Rescue on Thursday';
case 5
Day = 'Rescue on Friday';
case 6
Day = 'Rescue on Saturday';
case 7
Day = 'Rescue on Sunday';
otherwise
disp('Decoy message: Invalid rescue day.');
failed = true;
end
F1 = str2double(C1(4));
F2 = str2double(C1(5));
F3 = str2double(C1(6));
if mod(F1,3) == 0
B = F2 - F3;
else
B = F3 - F2;
end
if ~failed
switch(B)
case 1
Position = ' at the bridge.';
case 2
Position = ' at the library.';
case 3
Position = ' at the river crossing.';
case 4
Position = ' at the airport.';
case 5
Position = ' at the bus terminal.';
case 6
Position = ' at the hospital.';
case 7
Position = ' at St. Petes Church.';
otherwise
disp('Decoy message: Invalid rendezvous point.');
end
disp([Day , Position])
end
end
end
If I enter 918990， I do get what I want, it will show Decoy message: Invalid rendezvous point. But there will appear an error message, how I can debug this?Minhao Wanghttps://in.mathworks.com/matlabcentral/profile/authors/19395651tag:in.mathworks.com,2005:Question/6015972020-09-28T22:56:18Z2020-09-29T02:21:00ZWhy am I getting "Array indices must be positive or integers values"? This is a sine function, which should give me positive and negative values.
syms t
t = 0:0.02:2;
om = 10;
% Steady State Response
up(t)=(100/(400-om^2))*sin(om*t);
plot(t,up(t))
xlabel('Time (sec)')
ylabel('Displacement (in)')
title('Displacement vs Time Response')
Array indices must be positive integers or logical values.
Error in HW5plot (line 6)
up(t)=(100/(400-om^2))*sin(om*t); Edgar Sorianohttps://in.mathworks.com/matlabcentral/profile/authors/9228590tag:in.mathworks.com,2005:Question/6014982020-09-28T19:37:41Z2020-09-29T02:18:22ZCan you plot polarplots so that theta zero location is at any arbitrary angle or are top left bottom right the only options?I would like to plot a polar plot so that the top angle is the heading of a vehicle like you would see in a navigation display. Is there a way to do this? I tried using the view function to change the angle but it failed. Is there a way to change ax.ThetaZeroLocation to an angle instead of the four options listed?Ryan Rosehttps://in.mathworks.com/matlabcentral/profile/authors/11998796tag:in.mathworks.com,2005:Question/5883012020-09-03T06:46:50Z2020-09-29T02:18:15ZNeural network training - 2 input parameter to 1 output result trainingim stuck at training net with 2 parameter.
right now im trying to clasify test data. by using example "Classify Text Data Using Deep Learning".
for that example if i want to have "description" and "category" as training input and "resolution" as target output.
which part of code in the example that i have to change.
i need help Ridza Effendi Abd Razakhttps://in.mathworks.com/matlabcentral/profile/authors/18802768tag:in.mathworks.com,2005:Question/6015762020-09-28T21:44:01Z2020-09-29T02:18:15Zcan't find the solution of the equationsyms x
m1=5.97*10^24;
m2=7.35*10^22;
D=linspace(3.8*10^8,4.0*10^8,41);
eqn=m1.*((D-x).^2)==m2*(x^2)
solx(eqn,x)xihao zenghttps://in.mathworks.com/matlabcentral/profile/authors/18904055tag:in.mathworks.com,2005:Question/271732012-01-26T20:35:34Z2020-09-29T02:15:33ZMEX Files still open in MatlabHello,
I'm actually compiling CUDA mex files in Matlab by first using the system command nvcc (which is Nvidia's compiler for CUDA C code) to compile my .cu code into .cpp code, and then using the mex command to compile that into mex code. It will work out fine until I try to make some changes and then recompile. When I do , I get the Link: fatal error LNK1104 error where it says that it can't open the target mex file. Even when I try to delete the existing .mexw64 file, it says that the file is still open in Matlab. Once I restart Matlab, I can recompile. How can I remedy this error?
Thanks,
MattMatthttps://in.mathworks.com/matlabcentral/profile/authors/3276253tag:in.mathworks.com,2005:Question/6016482020-09-29T01:32:53Z2020-09-29T02:09:38ZHow can i implement subtraction without using for-loop ?I have a vector J 1000x7 and a vector K 16x7
I want to take each row of J(one at a time) an subtract it from every row of K.
For example i want to take the first row of J and subtract it from each row of K and then take the 2nd row of J and do the same .
How can i implement this without using for-loop (because for loop is too slow for my programm).
Gn Gnkhttps://in.mathworks.com/matlabcentral/profile/authors/16544080tag:in.mathworks.com,2005:Question/6015432020-09-28T20:31:07Z2020-09-29T01:46:55ZDensity-Temperature diagramI have a semilog diagram with temperature (y axis) and viscosity(x axis). The diagram is linear. I need an equation that returns viscosity's values entering a particular value of temperature. How can i do? I've tried something like this, but it's totally wrong:
x =[10,50];
y =[50,0];
C = polyfit(log10(x),y,1)
m = C(1);
k = C(2);
T = 100;
vi = polyval(C,log10(x));Valeria Fedelehttps://in.mathworks.com/matlabcentral/profile/authors/9935369tag:in.mathworks.com,2005:Question/6015522020-09-28T20:46:19Z2020-09-29T01:46:26ZHow to plot non-square 3 dimensional matrix? Hi all,
I have some climate data that I'm having a hard time visualzing in MATLAB. I have 3D temperature matrix with dimensions of 65x49x20. I also have vectors of latitude(49x1), longitude (65x1), and altitude (20x1). I've tried creating a meshgrid out of lat, lon, and altitude, and then scatter3/surf/mesh the meshgrid with the 3D temperature data (e.g. scatter3(xmg,ymg,zmg,T)), but keep running into errors about vectors not being the same length. But everything is the same size! the temp matrix as well as the meshgrid I've created all have the same dimensions, yet I can't seem to be able to plot anything. Anyone have ideas of what I'm doing wrong?
Thanks,
TylerTyler Paladinohttps://in.mathworks.com/matlabcentral/profile/authors/17347778tag:in.mathworks.com,2005:Question/5944962020-09-16T07:10:09Z2020-09-29T01:45:44ZThe force on a cylinder near a wall in viscous potential flowsMyo Gyihttps://in.mathworks.com/matlabcentral/profile/authors/9196398tag:in.mathworks.com,2005:Question/3455672017-06-13T04:00:00Z2020-09-29T01:44:06ZWhy am I unable to connect to Arduino in External Mode?When I try to run my model in external mode with Arduino Mega connected, I receive the following error:
---------------------------
### Starting build procedure for model: model1_test
Code Generation 1
Elapsed: 1:04 min
AVR Memory Usage
----------------
Device: atmega2560
Program: 24764 bytes (9.4% Full)
(.text + .data + .bootloader)
Data: 1769 bytes (21.6% Full)
(.data + .bss + .noinit)
### Successful completion of build procedure for model: model1_test
Build process completed successfully
Attempting to establish connection with hostname '127.0.0.1' through port 17725.
action: EXT_CONNECT
Component:Simulink | Category:Model
Error occurred while executing External Mode MEX-file 'ext_comm':
Failed to connect to the target. Possible reasons for the failure:
a) The target is not switched on.
b) The target is not connected to your host machine.
c) The application for the model is not running on the target. You might have clicked the Stop button. If the Run button is not dimmed, click it. Otherwise, click the Build button, which downloads and runs your application on the target.
Caused by:
An error occurred attempting to open an rtIOStream. More detail may be reported in the MATLAB command window
Component:Simulink | Category:Block diagram error
Unable to connect to the 'Arduino Mega 2560' target for 'model1_test'.
MathWorks Support Teamhttps://in.mathworks.com/matlabcentral/profile/authors/4622813