https://jp.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — 新規の質問2021-05-06T07:36:59Ztag:jp.mathworks.com,2005:Question/3169342016-12-15T00:29:16Z2021-05-06T07:36:13ZHow can I add a curve to both bode graphs?So I have a single bode graph, with gain and phase response. And I'd like to add one curve to each graph, not sure how I can do it.
I have tried to use hold on, but didnt work so well.
<</matlabcentral/answers/uploaded_files/65548/%E6%9C%AA%E6%A0%87%E9%A2%98-1.jpg>>
Below is the code I used.
if true
csvname = 'Book1.csv';
Gain = csvread(csvname,1,0,[1,0,32,1]);
Phase = csvread(csvname,35,0,[35,0,66,1]);
H = tf(1,[0.01,1])
bode (H,{10,1000})
hold on;
grid on;
plot(Gain(:,1), Gain(:,2))
plot(Phase(:,1), Phase(:,2))
end
Many thanks.Sean Sunhttps://jp.mathworks.com/matlabcentral/profile/authors/7379907tag:jp.mathworks.com,2005:Question/8227952021-05-06T07:35:50Z2021-05-06T07:35:50ZBoxplot and histogram in one plot Hey,
I think this question has been asked before:
How to overlay box plot with distribution histogram in the same graph - MATLAB Answers - MATLAB Central (mathworks.com)
But I could not find any proper solution;
so is there a way to achieve something like this:
I'm looking forward to hear your solutions :)
Jakob Seiferthttps://jp.mathworks.com/matlabcentral/profile/authors/21804680tag:jp.mathworks.com,2005:Question/8227702021-05-06T06:28:58Z2021-05-06T07:29:24Zhow can i use for loop for this scriptfor b=1:1:1200
omega(b)=b;
Omega(b)=omega(b)*2*pi;
alpa=-(roh*omega(b)^2/E)-(roh*omega(b)/k*G);
beta=-(roh*A*omega(b)^2/E*I)-(roh^2*omega(b)^4/E*k*G);
for j=1:4
k_j(b) =(-1)^(j(b)/2)*([sqrt(alpa+(-1)^j(b))*sqrt((alpa)^2+4*beta)/2]);
k1(b)=k_j(b);
k2(b)=k_j(b);
k3(b)=k_j(b);
k4(b)=k_j(b);shoaib Shoaibhttps://jp.mathworks.com/matlabcentral/profile/authors/17062558tag:jp.mathworks.com,2005:Question/6689332020-11-30T07:27:21Z2021-05-06T07:27:42ZHow to improve my regression problem having a low accuracy? I want to solve a small regression problem. My dataset consists of two features:
the population of a country
the number of representatives
So, my objective is: given the population of a country I get the estimated number of representative. The issue is that the using linear regression I get a 50% of accuracy. Can this be be motivated by the distribution of the data? Here some descriptors of the dataset:
And here my scatter plot:
I am new in ML and I'm trying to do some stuff by myself. How can I improve my model? I was thinking:
use a non linear regression to better fit the data
improve my dataset (e.g. removing outliers)
_______________________
Pursuing Data Scientist Course.Tobi Marshhttps://jp.mathworks.com/matlabcentral/profile/authors/19800653tag:jp.mathworks.com,2005:Question/8203252021-05-03T11:54:15Z2021-05-06T07:26:22ZHow to read and write some registers of a client machine over ModBus TCP/IP on Simulink.Hi, my name is Daniel, and I’m trying to read and write some vales from some MODBUS TCP registers from a converter with simulink blocks.
I have achieved it using Matlab functions and with the "Interpreted Matlab function" block, through the write and read functions. But this works quite slow.
Is there a way where I can read and write to certain registers from simulink using MODBUS?
I have tried several Matlab blocks, but I am not able to read or write the desired registers (i.e. dir. 17000, 16856 ..)
Thank you very much in advance.
All the best.
DanielDaniel del Rivero Peñahttps://jp.mathworks.com/matlabcentral/profile/authors/17220324tag:jp.mathworks.com,2005:Question/7063232020-12-31T22:34:59Z2021-05-06T07:25:20ZImporting EEG edf to matlab
Hi guys having this error message when importing EEG/EDF format into matlab. What can I do. Complete newbie. Mubeen Janmohamedhttps://jp.mathworks.com/matlabcentral/profile/authors/15468326tag:jp.mathworks.com,2005:Question/8227502021-05-06T06:14:26Z2021-05-06T07:24:00Z1周期のみのAC電源はあるか1周期のみのAC Voltage sourceが必要なのですがありますか。
また作れる場合、どのように作れるか知りたいです。MISUMI MATSUMOTOhttps://jp.mathworks.com/matlabcentral/profile/authors/18818406tag:jp.mathworks.com,2005:Question/8160652021-04-28T17:52:34Z2021-05-06T07:19:45ZExecution of script vgg16 as a function is not supported:When I am trying to execute the vgg16 in matlab in IOS, I am getting this error.
Execution of script vgg16 as a function is not supported:
Error in vgg16own (line 16)
net = vgg16;Rallapalli Sethumadhavihttps://jp.mathworks.com/matlabcentral/profile/authors/12216814tag:jp.mathworks.com,2005:Question/8227902021-05-06T07:10:35Z2021-05-06T07:19:32ZHow to replace elements in a table using loops or any other method ?I am trying as an exercise to replace all elements in a table and I cannot figure it out. I am fairly new to Matlab and basic programming skills are not helping on this. Maybe thngs work different here.
So I have created an excel file with 23 rows and 2 columns with first column containing either 'Y' or 'N' for yes and no & the other with 2 digit number. I imported it as table
as shown.
Then I extracted it into 2 tables with each columns.
I want to convert the table with 'Y' and 'N' to have either 1 or 0 based on Y & N. But using loop is not getting me anywhere. What am I doing wrong / What is the correct method to do this ?JIYON PJhttps://jp.mathworks.com/matlabcentral/profile/authors/18768827tag:jp.mathworks.com,2005:Question/1261802014-04-17T22:28:57Z2021-05-06T07:17:37ZRegression Equation from artificial neural networkHi, I have 3 Input Data (temperature, moisture content, and frequency) set of 168 and
my target data (dielectric constant) set of 168.
I used an artificial neural network toolbox to get a regression model to generate simulated data.
I trained(70%), validated (15%), and tested(15%) it. I got reasonable result.
<</matlabcentral/answers/uploaded_files/11540/regression.jpg>>
<</matlabcentral/answers/uploaded_files/11541/result.jpg>>
Once i got the result is it possible to extract the regression equation from result.
If it is possible, which section should I click to get the regression model??
If I am not able to get the regression model directly, how can I get other information like bias, weight, and structure of neural network model to generate the regression model in directly or manually?daeung Yuhttps://jp.mathworks.com/matlabcentral/profile/authors/5262343tag:jp.mathworks.com,2005:Question/8225452021-05-05T22:13:16Z2021-05-06T07:17:07ZHow to clear a particular figure and replace it with otherSo I have got a curve f in green which I want to keep as it is. I have plot a blue circle over it. Now I want to clear this blue circle by keeping the green curve as it is and plot a new red circle over it. How should I do it?
clf
hold on
fplot(f,'g')
xlim([-1,3])
ylim([-2,2])
p1 = plot(0,0,'bo');
clf(p1,'reset')
p2 = plot(0,1,'ro');
Yash Phirkehttps://jp.mathworks.com/matlabcentral/profile/authors/20238230tag:jp.mathworks.com,2005:Question/3836122018-02-20T02:13:18Z2021-05-06T07:16:42ZHow to average different transfer functions in order to obtain a global one?I am trying to obtain a transfer function from experimental data of different tests. The thing is that for each test I obtain different transfer functions using the System Identification Toolbox, what would be the average transfer function that best fits all the tests?Franciscohttps://jp.mathworks.com/matlabcentral/profile/authors/10767809tag:jp.mathworks.com,2005:Question/1117772014-01-08T15:51:34Z2021-05-06T07:16:28ZHOW TO AVERAGE TRANSFER FUNCTIONSHi, I am exciting a structure with white noise to get its transfer function. The function I am using is tfestimate.
Suppose I use a longer excitation signal: I was wondering if I can split it, calculate more transfer functions and then average them: how can I do this in MatLab? It is possible using tfestimate?
Another thing what I was wondering is does the overlap influence the goodness of the transfer function? If so, how?
Thanks in advance,
Best regardsFrancescohttps://jp.mathworks.com/matlabcentral/profile/authors/4316805tag:jp.mathworks.com,2005:Question/8220302021-05-05T10:03:46Z2021-05-06T07:15:15Zhow to change the markers and line style, for 'findpeaks' ?Hello, According to the next code, how can I change the ‘markers’ and line style using the ‘findpeaks’ function? Thank you.
[pks,locs,widths,proms] = findpeaks(pws(:,end),y,'MinPeakHeight',trd);
findpeaks(pws(:,end),y,'Annotate','extents','WidthReference','halfprom');
text(locs+0.5,pks,num2str((1:numel(pks))'));
legend('Filtered Data','Peak','Prominence','Width','FontSize',5);
Fercho_Salahttps://jp.mathworks.com/matlabcentral/profile/authors/21300178tag:jp.mathworks.com,2005:Question/8170852021-04-29T15:11:05Z2021-05-06T07:14:02Zintegrate pyton script in a standalone Matlab app i'm trying to develop a standalone matlab app but with some python script in it. when i run the code in app designer, it works fine but when i compile the standalone app, it doesn't work. when packaging I include the python script and the python folder (oct_converter) which it's necessary and also the init.py and the package looks fine I guess. I also commented the lines where I called python and develop another standalone app and it worked so I think it's definitely the use of python script. also since it's the standalone app, it doesn't show me any erorr message it just crashes
I'm running matlab R2020b on macOS frederic tchuisseuhttps://jp.mathworks.com/matlabcentral/profile/authors/16195063tag:jp.mathworks.com,2005:Question/8209702021-05-04T05:19:03Z2021-05-06T07:11:42ZInstalling standalone .exe application using matlab runtime installer.I have packaged a standalone application using Matlab Compiler(R2020a). At that time, I did not have option to choose the matlab runtime version with which I want to package my application. Is it possible to install an app packaged with matlab runtime 9.8 in another device which has matlab runtime 9.4? if not is there any other way to do it??Vinayak Untwalehttps://jp.mathworks.com/matlabcentral/profile/authors/16055121tag:jp.mathworks.com,2005:Question/8227652021-05-06T06:25:01Z2021-05-06T07:36:59Zcount of points in particular region from graph graph is plot of scattered points , graph is also divided into grids of size 64*64. i need the count of number of points in each grid .
if a 32*32 (-1024 to 1024)matrix is taken such that each grid is represented by a value(count ) in matrix . any help is highly appretiated thanks SINDU GOKULAPATIhttps://jp.mathworks.com/matlabcentral/profile/authors/16460274tag:jp.mathworks.com,2005:Question/8204352021-05-03T13:39:54Z2021-05-06T07:04:10Zwhile loop while measurementHello i execute a measurement with:
state = app.measurement.ExecuteMeasurement();
Now i want to program a blink led while the measurement ist running. But i dont know how to program the while loop.
Many regardsTheDicehttps://jp.mathworks.com/matlabcentral/profile/authors/13811151tag:jp.mathworks.com,2005:Question/8225852021-05-06T00:57:26Z2021-05-06T07:03:52ZCreate Moving Average filter WITHOUT filter() functionHello,
I can't seem to plot a desired output using a Hanning Moving Average equation. My goal is to create a moving average filter with a 3-point moving average with a created signal x. However, I don't notice a difference between the unfiltered signal and the filtered signal. May someone give advice on how to enter a moving average equation and it's coefficients without the use of the filter() function? Or is the 3-point moving average so small that there isn't a difference?
Hanning Moving Average filter:
y[n] = 1/4(x[n] + 2x[n-1] + x[n-2]).
fs = 200; %sampling frequency
Ts = 1/200; %sampling time
t = 0:Ts:1;
x = sin(2*pi*2*t) + sin(2*pi*10*t) + sin(2*pi*90*t) %signal
plot(t,x); %unfiltered signal
title('Signal with 2, 10, and 90 Hz');
xlabel('time (s)');
%Difference equation of Hanning Moving Average filter:
n = 3
yn = (.25*x(n)) + (.5*x*(n-1)) + (.25*(n-2)) %Attempt at creating the moving average equation.
plot(t,yn)
Thank You
Terry Carneyhttps://jp.mathworks.com/matlabcentral/profile/authors/16179111tag:jp.mathworks.com,2005:Question/8210052021-05-04T06:41:34Z2021-05-06T07:02:20ZHow to solve the second-oder differential equations with two variables using ODE45 or whateverHello,
I'm trying to solve the following equations using ODE45 but I'm not confident that my codes work correct. So please teach me whether the codes are correct or not, and if not, teach me how I can analyze the equation numerically.
----—the equation———
mx’’+Dx’+Kx=-f
Tf’ + f = Gx
%parameters
m=3
D=2
K=1
T=1
G=5
%variables
x, f
———my codes———
% I know ode45 only can solve one oder differential equations so I did a change of variables. However I would rather avoid using this change because it’s hard to see x and f in a plotted graph with the new variable appearing on it.
m=3
D=2
K=1
T=1
G=5
% I did the following change [X=x’] so the equation becomes[ X=x’ ][mX’+DX+Kx=-f][Tf’ + f = Gx]
%F(1) matches x, F(2) matches X, F(3) matches f
% x(0)=0.5
[t,F]=ode45(@(t,F)[F(2);(-F(3)-D*F(2)-K*F(1))/m;(G*F(1)+F(3))/T],[0,1],[0.5,0,0]);
plot(t,F);
嵩人 藤森https://jp.mathworks.com/matlabcentral/profile/authors/21657812tag:jp.mathworks.com,2005:Question/8227852021-05-06T06:57:57Z2021-05-06T06:59:23ZHow can I run uifigure over uiaxes inside my app? Hi All,
I have written the following code to run one uiprogress (as a waitbar) as computing process is in progress. It runs properly via uifigure but I need to run it over UIAxes within my GUI environment (developed by app designer). Would you please have a look and kindly correct my code (if possible)?
Many Thanks,
Moh
*****************************************
function CalculationButtonPushed(app, event)
fig = uifigure;
d = uiprogressdlg(fig,'Message','In progress','Title','Computing SVD',...
'Indeterminate','on');
drawnow
% Execute the computation
[u s v] = svds(rand(50000,200),10);
sc = u*s;
% close the dialog box
close(d)
close(fig)
endMohammad Shahbazyhttps://jp.mathworks.com/matlabcentral/profile/authors/16922500tag:jp.mathworks.com,2005:Question/6031362020-10-01T11:43:48Z2021-05-06T06:52:15ZWorking with Ouster lidar UDP packetsHello,
Can anyone reply how to calculate point cloud data from the raw UDP packets received from the Ouster LIDAR sensor?
Regards,
VenkatVenkatesan Ponramanhttps://jp.mathworks.com/matlabcentral/profile/authors/7261486tag:jp.mathworks.com,2005:Question/8223252021-05-05T16:21:35Z2021-05-06T06:52:07ZCustomize tick values in boxplotHey,
I have the following boxplot:
Instead of 1, 2, 3 on the x-axis I want to have 50kW, 150kW, 300kW - I tried changing tick-values to either only 50, 150, 300 or with kW. Both wont work, as obviously these are not regular tick values. Is there a way to customize it, to have it display what I need?Lukas Netzerhttps://jp.mathworks.com/matlabcentral/profile/authors/21912095tag:jp.mathworks.com,2005:Question/8227552021-05-06T06:17:49Z2021-05-06T06:45:20ZHave index of numbers and letters in titleI try to setup the title for one of my boxplots to use an index like that:
t{n} = abc123abc;
I tried using:
title('title', t{n})
title('title', string(t{n}))
title('title t{n]')
etc.
Is there a way to do it?Lukas Netzerhttps://jp.mathworks.com/matlabcentral/profile/authors/21912095tag:jp.mathworks.com,2005:Question/8219802021-05-05T08:34:58Z2021-05-06T06:45:02ZAssigning multiple variables a single legendI have script that plots bar charts for different sleep stages across 'trials'. I want to club one stage from each trial and assign it a color in the legend but I'm unable to do so. The script:
%% NREM
hold on;
h1=bar(categorical({'PT5',}),size(PT5_Changed.NREM_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','b');
h2=bar(categorical({'PT4',}),size(PT4_Changed.NREM_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','b');
h3=bar(categorical({'PT3',}),size(PT3_Changed.NREM_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','b');
h4=bar(categorical({'PT2',}),size(PT2_Changed.NREM_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','b');
h5=bar(categorical({'PT1',}),size(PT1_Changed.NREM_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','b');
%% REM
h6=bar(categorical({'PT5',}),size(PT5_Changed.REM_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','r');
h7=bar(categorical({'PT4',}),size(PT4_Changed.REM_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','r');
h8=bar(categorical({'PT3',}),size(PT3_Changed.REM_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','r');
h9=bar(categorical({'PT2',}),size(PT2_Changed.REM_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','r');
h10=bar(categorical({'PT1',}),size(PT1_Changed.NREM_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','r');
%% Intermediate
bar(categorical({'PT5',}),size(PT5_Changed.Intermediate_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','g');
bar(categorical({'PT4',}),size(PT4_Changed.Intermediate_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','g');
bar(categorical({'PT3',}),size(PT3_Changed.Intermediate_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','g');
bar(categorical({'PT2',}),size(PT2_Changed.Intermediate_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','g');
bar(categorical({'PT1',}),size(PT1_Changed.Intermediate_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','g');
%% Quiet Wake
bar(categorical({'PT5',}),size(PT5_Changed.Quiet_Wake_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','y');
bar(categorical({'PT4',}),size(PT4_Changed.Quiet_Wake_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','y');
bar(categorical({'PT3',}),size(PT3_Changed.Quiet_Wake_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','y');
bar(categorical({'PT2',}),size(PT2_Changed.Quiet_Wake_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','y');
bar(categorical({'PT1',}),size(PT1_Changed.Quiet_Wake_Bout_Wise_Firing_Rate,1),0.1,'FaceColor','y');
legend('NREM','REM','Intermediate','Quiet Wake')
ylabel('Number of Bouts');xlabel('Rest Periods')
title(strcat('threshold matrix=','[400 30 3 30]',' , ','window size=','5s',',', ' ','overlap=',num2str(0)),'Interpreter','none')
When I plot this, I get the picture shown below. I need all categories to be the color I assigned them. Thanks for helping out!
shekhar narayananhttps://jp.mathworks.com/matlabcentral/profile/authors/11948091tag:jp.mathworks.com,2005:Question/8220002021-05-05T09:27:18Z2021-05-06T06:43:42Zsimulink fixed point advisor example file I was going through the tutorial on fixed point adviser from the weblink https://www.mathworks.com/videos/introducing-fixed-point-designer-for-matlab-and-simulink-81554.html. Can anybody provide the example for download that is demonstated in the tutorial?Garyhttps://jp.mathworks.com/matlabcentral/profile/authors/12414499tag:jp.mathworks.com,2005:Question/8227452021-05-06T06:11:58Z2021-05-06T06:37:54ZHow to make operation row by rowHello experts,
below is my code to get result A.
Alpha_pmp is 400,000 row data
AirTemp is 105200 row data
Tstc is 400,000 row data
below is the formula to calculate A value.
i can get all the result by using below code:
FtempN =((1 + (Alpha_pmp(1)).* (AirTemp(:,1)-(Tstc(1)))))
if i use above code matlab will return on single row result.
my question is how to to calculate result A by read row by row
for Alpha_pmp and Tstc?
example :
FtempN =((1 + (Alpha_pmp(2)).* (AirTemp(:,1)-(Tstc(2)))))
FtempN =((1 + (Alpha_pmp(3)).* (AirTemp(:,1)-(Tstc(3)))))
FtempN =((1 + (Alpha_pmp(4)).* (AirTemp(:,1)-(Tstc(4)))))
FtempN =((1 + (Alpha_pmp(5)).* (AirTemp(:,1)-(Tstc(5)))))
FtempN =((1 + (Alpha_pmp(6)).* (AirTemp(:,1)-(Tstc(6)))))
until last row.
Thank you.
note : i am newbie.I tried to make some research on matlab web but not luck.Shahid Saidhttps://jp.mathworks.com/matlabcentral/profile/authors/10579605tag:jp.mathworks.com,2005:Question/7823132021-03-24T13:15:27Z2021-05-06T06:33:22ZButton Press using ArduinoHow would I be able to detect a button press using an arduino so that everytime the button is pressed a variable gets its value reduced by 1?Braxton Goblehttps://jp.mathworks.com/matlabcentral/profile/authors/21984408tag:jp.mathworks.com,2005:Question/7902992021-04-01T19:09:43Z2021-05-06T06:28:52ZProblem with code readVoltajeI´m doing a project with ad8232 sensor and arduino uno, but MatLab is sending me the coding error:
Undefined function 'readVoltage'
Error in ECGCONcod (line 7)
voltaje=readVoltaje(a,'A0');
I really don´t know what to do, please I need help
Here is the complete code:
a= arduino('com4','uno');
x=0;
for k=1:1000
voltaje=readVoltaje(a,'A0');
x=[x,voltaje];
plot (x);
grid on;
drawnow;
end Isaac Vielma Aquinohttps://jp.mathworks.com/matlabcentral/profile/authors/22048161tag:jp.mathworks.com,2005:Question/7909192021-04-02T14:09:44Z2021-05-06T06:26:05Zcannot connect arduino MKRZero to MATLAB2019bHi, Hi. I'm getting the error in the attached file when trying to set up the arduino MKRZero following instruction from the Arduino ESP8266.
can someone helps me?
Thanksrojrojhttps://jp.mathworks.com/matlabcentral/profile/authors/13082326tag:jp.mathworks.com,2005:Question/8227352021-05-06T05:58:54Z2021-05-06T06:24:30ZHELP, i dont know how to write code for thisWrite a Matlab function that will accept variable number of arguments. If it receives no argument, it will return 'Hello'. If it receives one scalar argument, it will return a structure having one field named 'first' with the value of that scalar argument. If it receives one array, it will return the first column of that array. If it receives two arrays of correct size (same inner dimensions) it will return the product (matrix multiplication) of these arrays, otherwise it returns the product of the top right element of the first array and the bottom right element of the second array. If more than two arguments are received it will return 'unknown case'.Cooper Joneshttps://jp.mathworks.com/matlabcentral/profile/authors/21728799tag:jp.mathworks.com,2005:Question/8227602021-05-06T06:20:24Z2021-05-06T06:20:24ZAny Matlab Tutors ?Is there any Matlab tutors that can help, in-person or virtually? salem shehadehhttps://jp.mathworks.com/matlabcentral/profile/authors/22451440tag:jp.mathworks.com,2005:Question/8197252021-05-02T17:14:50Z2021-05-06T06:19:43ZI could not integrate using MatLab, Can you please help me? In solving a problem I need to integrate the following function with respect to 't' from the limit 0 to t.
3*2^(1/2)*(1 - cos(4*t))^(1/2)*(a^2 + c^2)^(1/2)
I used the following commands but got the same result as given herewith.
>> syms a c t real
mag_dr = 3*2^(1/2)*(1 - cos(4*t))^(1/2)*(a^2 + c^2)^(1/2)
>> int(mag_dr,t,0,t)
ans =
int(3*2^(1/2)*(1 - cos(4*t))^(1/2)*(a^2 + c^2)^(1/2), t, 0, t)
Let me know the best way(s) to tackle this type of problem. Tika Ram Pokhrelhttps://jp.mathworks.com/matlabcentral/profile/authors/21396991tag:jp.mathworks.com,2005:Question/8007212021-04-13T09:45:48Z2021-05-06T06:18:09ZInserting the Arduino hardware support package into a standalone executable does not workHi,
I want to create a Standalone executable from my Matlab code m. file.
The problem is that I am using the Arduino hardware support package and I am
can not include this when creating the exe. File.
I am currently using the R2016b version of Matlab.
The "Suggested Support Packages" option is not be shown in the compailer tool.
My question is how can I get the hardware support package into that
Include stand-alone executable. And is there another possibility
to create the standalone executable with the Arduino hardware support package?Aydin Caliskanhttps://jp.mathworks.com/matlabcentral/profile/authors/22187724tag:jp.mathworks.com,2005:Question/8210952021-05-04T09:07:40Z2021-05-06T06:16:48ZRaspberry Pi - MQTT Publish & MQTT Subscribe- Updating Multiple Fields In one MQTT publish request and vice versaHello,
I am working on raspberry pi with MQTT publish block. It is being used with Thingspeak Platform. I understood the example models for publiash and subscribe the fields.
I want to use the MQTT publish and Subscribe block for multiple fields of channel. I am struggling with proper Topic argument for both publish and subscribe blocks.
As I am bengineer, I will be happy to further explain the problem statement if the info given is insufficient.
I used floowing links as refernece but not understood the specific argument.
Publish message to update multiple channel fields simultaneously - MATLAB - MathWorks India
Subscribe to updates from channel feed with MQTT - MATLAB - MathWorks India
Regards
VISHAL SAWANThttps://jp.mathworks.com/matlabcentral/profile/authors/5618193tag:jp.mathworks.com,2005:Question/8158752021-04-28T14:18:06Z2021-05-06T06:12:57ZGUIDEで作成したGUIアプリが開かなくなりましたGUIDEでGUIアプリを作製して使用していましたが、.mファイルから実行しても、まったく反応せず、動かなくなりました。
本日夕方までは使えていました。また、他の以前に作製したGUIアプリは通常通り使えます。
GUIDEから.figファイルを開き、実行（再生アイコン）を押してもまったく反応しません
matlab2017ｂを使用しています。
ファイルの名前を変えて保存してもＧＵＩに表示されるファイル名が以前のままで変わりません。
同様の事象が起こった方で解決策をご存知の方がおられたらご教示ください。
Masashi Miharahttps://jp.mathworks.com/matlabcentral/profile/authors/17416400tag:jp.mathworks.com,2005:Question/8127302021-04-25T13:35:13Z2021-05-06T06:10:44ZTest Connection Failed Arduini MKR1010 WiFi via Matlab Support Package for ArduinoHi everyone,
I'm reaching out for help because I can't connect my Arduino MKR1010 Wifi to Matlab via the arduinosetup command; I keep getting the following error at the end of the procedure: "Test Connection Failed. Go back to check your settings.".
Over the last couple of days I've tried the following (with no success):
updated the Wifi Nina firmware to 1.2.2 (I've also tried the 1.2.1, which didn't make any difference so I came back to the latest version, the 1.2.2). Source: https://fr.mathworks.com/help/supportpkg/arduinoio/ug/board-specific-issues.html
tried on a different LAN than my household's; with only my computer and the Arduino on the router, while respecting the default Gateway and the subnet Mask mentionned in following tutorial: https://fr.mathworks.com/help/supportpkg/arduinoio/ug/configure-setup-for-arduino-hardware.html
both static and dynamic IP fail the connection test; even though the Arduino responds to my pings
I'm currently using an academic version of Matlab 2020b (I'm a college student), I'm going to try again on Matlab 2019b.
I should mention that the arduino was purchased 2 days ago for that very purpose, and that it works just fine in the Arduino IDE and while connected to a COM-port on Matlab. I don't think there's a hardware related issue with the Arduino.
I would really appreciate your help if you have stumbled upon a similar issue, if you have any piece of advice or idea that I should try out.
Thanks in advance.
MichaelMichael Schaetzelhttps://jp.mathworks.com/matlabcentral/profile/authors/16972362tag:jp.mathworks.com,2005:Question/8227402021-05-06T06:09:24Z2021-05-06T06:09:43ZSubset a table based on a column and another vectorSo I have a table of values and one of the columns is patient_number. I have another vector of patient numbers I want to get information about from the table.
How do I subset the table based on the second vector that I have? I want the resulting subset to be in the same order of the subseting vector.
Thanks!Steven Vitshttps://jp.mathworks.com/matlabcentral/profile/authors/18888997tag:jp.mathworks.com,2005:Question/8216852021-05-04T21:45:23Z2021-05-06T06:07:55ZHow to get norm (magnitude) of a vector the simple way? I just want to get the norm of
c = [-cos(phi)*sin(the)^2 -sin(phi)*sin(the)^2 - cos(the)*sin(the)*cos(phi)^2 - cos(the)*sin(the)*sin(phi)^2]
norm(c,2)
isn't really simplifying anything
If I type it manually:
simplify(sqrt(cos(phi)^2*sin(the)^4+sin(phi)^2*sin(the)^4+sin(the)^2*cos(the)^2))
I get a simple answere:
(sin(the)^2)^(1/2)Niklas Kurzhttps://jp.mathworks.com/matlabcentral/profile/authors/18516014tag:jp.mathworks.com,2005:Question/8226952021-05-06T05:01:08Z2021-05-06T06:06:52ZHow do I replicate curve fit figure with an equation?I would like to replicate the following plane, which was plotted with the curve fitting toolbox.
The toolbox gave me this information for the plane:
% Linear model Poly22:
% ans(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2
% where x is normalized by mean 14.91 and std 0.5073
% and where y is normalized by mean -7.804 and std 23.72
% Coefficients (with 95% confidence bounds):
% p00 = -3.562 (-3.609, -3.516)
% p10 = -0.0439 (-0.1117, 0.02388)
% p01 = 22.79 (22.72, 22.85)
% p20 = 0.04982 (-0.08557, 0.1852)
% p11 = 0.06292 (-0.1923, 0.3182)
% p02 = 1.543 (1.41, 1.675)
But when I plot it with the code
p00 = -3.562 ; p10 = -0.0439 ; p01 = 22.79 ;
p20 = 0.04982 ; p11 = 0.06292 ; p02 = 1.543 ;
syms x y
z = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2;
fsurf(z, [13.5 16], 'edgecolor', 'none');
xlabel('x'); ylabel('y'); zlabel('z');
I do not get the proper coordinates and end up with this and I'm not sure how to fix it:
I think it has to do with the 'normalized by mean xx and std yy ' but I don't know how it worksMJhttps://jp.mathworks.com/matlabcentral/profile/authors/8648523tag:jp.mathworks.com,2005:Question/8194402021-05-02T12:09:20Z2021-05-06T06:02:28ZMatlab - Arduino Communicate --> Open failed: Port: COM6 is not available. No ports are available
Hi , everyone I need your helps.
I am working on a project that reqiured matlab-arduino communicate. But ı took a weird error and ı didnt solve it.
Error :
Error using serial/fopen (line 72)
Open failed: Port: COM6 is not available. No ports are available.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.
Error in Arduino (line 3)
fopen(s1);
when ı take this error. my arduino is connected to the COM6 but my matlab serial port says me it doesnt connect the COM6. thing that is weird, when ı started the matlab for the first , it working nice but when ı tried run the same script for second or third, it doesn't work . I mean ı take this error.
Please help me :/ it is so weird error. I haven't found it yet.
Arif Emre DEMIRhttps://jp.mathworks.com/matlabcentral/profile/authors/17146971tag:jp.mathworks.com,2005:Question/8226802021-05-06T04:42:26Z2021-05-06T06:02:17ZRemove a string from another stringI have two strings like 'bio-inspired' and 'bioinspired'. I want to essentially subtract one string from another and get '-' in the end. How can I delete all letters appearing in one string from another string? The erase function doesn't work for this case.Tejashttps://jp.mathworks.com/matlabcentral/profile/authors/18205581tag:jp.mathworks.com,2005:Question/8225952021-05-06T01:09:52Z2021-05-06T06:00:51ZADD two signal and make one signalRomana Alamhttps://jp.mathworks.com/matlabcentral/profile/authors/22308692tag:jp.mathworks.com,2005:Question/8227002021-05-06T05:04:40Z2021-05-06T05:58:52ZReinforcement learning LQR example questionIn the reinforcement learning guide, there is an example for training RL for solving discrete LQR problem.
https://www.mathworks.com/help/reinforcement-learning/ug/train-custom-lqr-agent.html
I want to modify the example to the case where not all the states are controllable nor observable.
This is the code in the given function
function env = myDiscreteEnv(A,B,Q,R)
% This function creates a discrete-time linear system environment.
%
% (A,B) are the system matrices, where dx = Ax + Bu.
% (Q,R) defines the quadratic cost, where r = x'Qx + u'Ru.
% Copyright 2018-2019 The MathWorks Inc.
% observation info
OINFO = rlNumericSpec([size(A,1),1]);
% action info
AINFO = rlNumericSpec([size(B,2),1]);
% environment
env = rlFunctionEnv(OINFO,AINFO,...
@(action,loggedSignals) myStepFunction(action,loggedSignals,A,B,Q,R),@() myResetFunction(Q));
end
function [Observation, Reward, IsDone, LoggedSignals] = myStepFunction(Action,LoggedSignals,A,B,Q,R)
% This is the step function for the environment, which returns the next
% observation for a given action.
% observations
x = LoggedSignals;
% dynamics
dx = A*x+B*Action;
Observation = dx;
LoggedSignals = dx;
% isDone
IsDone = false;
% Reward
Reward = -x'*Q*x -Action'*R*Action;
end
function [InitialObservation, LoggedSignals] = myResetFunction(Q)
% This is the reset function for the environment, which sets random initial
% conditions for the observation.
n = size(Q,1);
x0 = rand(n,1);
InitialObservation = x0;
LoggedSignals=InitialObservation;
end
If my system cannot observe all the states do I change observation or logged signal by selecting the elements of dx I want to observe?
I assume I need to change the observation because the x = logged signal line, implies that the actual system dynamics is obtained from logged signal. Obviously I need the system to simulate the entire dynamics but the controller to only have access to some of the state variables.
Also, does the system automatically know the number of controllers (actions) by the dimensions of R,B?
2)
I have a second question, how do I obtain the state values during the training steps? I am trying to simulate an online learner, thus I need the performance during the training stages too. The "trainingStats" commands only give me what the reward was, but I need to know the value of the observations(state variables) too. As I need to know the performance during the training and the deployement, not just during deployement like as shown in the example.hamad alduaijhttps://jp.mathworks.com/matlabcentral/profile/authors/7832547tag:jp.mathworks.com,2005:Question/8223402021-05-05T16:54:12Z2021-05-06T05:55:38Zwhy is the variable order in a user defined function important in lsqnonlin optimisation?I have a script which purpose is to optimise a fit of a function (func), in the function, beta0 is the input initial value for two coefficients. And y1, y2, y3 are data in column format (604X1). My codes for lsqnonlin optimisation and my function (func) looks like this:
[beta,resnorm,residual,exitflag,output,lambda,jacobian] = lsqnonlin(@Func,beta0,lb,ub,[],y1,y2,y3);
ci = nlparci(beta,residual,jacobian);
function f1 = Func(beta,y1,y2,y3)
f1 = y2 - beta(1)*y1 - beta(2)*y3 ;
end
when the input for Func writen in this way "Func(beta,y1,y2,y3) ", I optain the correct coefficients.
however if the variable order in the input for Func change to "Func(y1,y2,y3,beta) ", it returns with wrong coefficients.
Why does the order in the self defined function important for lsqnonlin fitting?
And, what is the relationship between the Func variables input order and lsqnonlin variables input order?
Thank you !Xiu Wen Kanghttps://jp.mathworks.com/matlabcentral/profile/authors/17309670tag:jp.mathworks.com,2005:Question/5219352020-04-30T10:02:07Z2021-05-06T05:35:29ZMatlab setup file not openingI recently got my Student use Matlab version. I downloaded the software from website. However on running the setup file in the extracted folder, the window for MATLAB opens and closes immediately. On Control panel, I see the the MATLAB Product installer process running for 2-3 seconds and then vanishes. Please help me with this. Mohammed Kamranhttps://jp.mathworks.com/matlabcentral/profile/authors/18332679tag:jp.mathworks.com,2005:Question/5053832020-02-13T20:05:36Z2021-05-06T05:25:42Zhow can I convert knnclassify to fitcknn
I have a script from a past graduate student that needs to be updated! i dont know matlab!
How do I swtich from knnclassify to fitcknn?Rachel Parisehttps://jp.mathworks.com/matlabcentral/profile/authors/13135580tag:jp.mathworks.com,2005:Question/8227302021-05-06T05:25:42Z2021-05-06T05:25:42ZGPR number of kernel scaleHi,all
I just use linear regression app to calculated 5-fold cross validation, (bayesian optimaztion). However, finally only one kernel scale provided.
the reviewer's comment:
As for the GPR model no-isotropic kernel function, the number of kernel scale is usually equal to the number of variables (xi). However, the authors mentioned in the Supporting Information that only one kernel scale was obtained. If it is such a case, the isotropic kernel function may be actually used. The similar issue also exists in the employed SVM model. The authors should check them again.
from the code, there are only two parameters
regressionGP = fitrgp(...
predictors, ...
response, ...
'BasisFunction', 'none', ...
'KernelFunction', 'exponential', ...
'KernelParameters', [0.1832775367419647 4.728824320552641], ...
'Sigma', 1.618591169127487, ...
'Standardize', true);
how to find other kernel scale?
Thank you!
Qiang Wanghttps://jp.mathworks.com/matlabcentral/profile/authors/13481503tag:jp.mathworks.com,2005:Question/8226552021-05-06T03:51:58Z2021-05-06T05:24:47ZUnable to perform assignment because the size of the left side is 8-by-1 and the size of the right side is 8-by-1001.I am getting this error where I am sure the size of the left-side = the right side in this code, what else can be causing this problem?
Unable to perform assignment because the size of the left side is 8-by-1 and the size of the right side is 8-by-1001.
Error in RK4
U_RK(:,j) = U_T(:,j)-(dt./dx)*a(k)*(Res);
function [ U_RK ] = RK4( U_T,Res, dx, dt, N,k )
U_RK = U_T;
a = zeros(4,1);
a(1) = 0.25;
a(2) = 1.0/3.0;
a(3) = 0.5;
a(4) = 1.0;
for j = 2:N-2
U_RK(:,j) = U_T(:,j)-(dt./dx)*a(k)*(Res); % error here
end
end
But U_Rk(:,j) is initailly set to = U_T, and is initizalize this way:
L = 1; %domain length
x = 0:dx:L;
N = length(x);
U_T= zeros(8,N);
So how is the LHS does not equal the RHS?? Lujain Almarhabihttps://jp.mathworks.com/matlabcentral/profile/authors/12080112tag:jp.mathworks.com,2005:Question/8227252021-05-06T05:21:49Z2021-05-06T05:21:49ZHow to integrate ODE45 solver in state flow?Hi!
I am trying to build a state flow model in matlab and one of the charts (in state flow) requires solving a system of differential equations. I am trying to embed ode45 in that. However for some reason it is throwing a lot of errors. Is there a formal way to embed ode45 solver into state flow? Please highlight with some link or example. Thanks and regards!!Amardeep Mishrahttps://jp.mathworks.com/matlabcentral/profile/authors/12345958