Category: Matlab
Category Archives: Matlab
Request about comment char % vs C++ //
I’m switching back and forth between C(++) for my Arduino Pico and MatLab App Designer
It would be really nice if when I type // to start a comment you could switch it to %
You have so much help in completion of typed stuff this shouldn’t be hard for next release.
I’m getting the hang of MatLab but it can still be irritationg for "real" programmers. :-)I’m switching back and forth between C(++) for my Arduino Pico and MatLab App Designer
It would be really nice if when I type // to start a comment you could switch it to %
You have so much help in completion of typed stuff this shouldn’t be hard for next release.
I’m getting the hang of MatLab but it can still be irritationg for "real" programmers. 🙂 I’m switching back and forth between C(++) for my Arduino Pico and MatLab App Designer
It would be really nice if when I type // to start a comment you could switch it to %
You have so much help in completion of typed stuff this shouldn’t be hard for next release.
I’m getting the hang of MatLab but it can still be irritationg for "real" programmers. 🙂 comment tag MATLAB Answers — New Questions
Filtering specific wavenumber range in Fourier Transforms result.
Hello. I am currently dealing with the interference signal from the Coherence Scanning interferometer. My plan for processing the signal is as follows:
Applying a discriminator to normalize the signal to the center amplitude at zero,
Zero padding the signal to increase the resolution in the frequency domain.
Doing FFT to convert the interference signal from scanning distance to spatial frequency domain ( um to rad/um).
Filtering out the interested domain ( my light source is 380 nm to 780 nm, so I only care about the range from 8 ~ 17 rad/um).
Calculating and unwrapping the phase from the filtered result.
Compensating the phase with the phase error calculated by material properties.
Doing IFFT with the compensated phase to convert it back to an interference signa
Figure 1. Original phase from interferogram.
Figure 2. Calculated phase error.
The problem is the wavenumber range of the interference signal is 0 to ~ 25 rad/um while the phase error I calculated only supports from 6~30 rad/um. I would like to know if there are any ways to take out entirely then wavenumber range from 8 ~17 rad/um and do the rest of my work on this range. I also shared my code and raw data here.
Thank you all for reading my problem. Hope you guys have a nice weekend.Hello. I am currently dealing with the interference signal from the Coherence Scanning interferometer. My plan for processing the signal is as follows:
Applying a discriminator to normalize the signal to the center amplitude at zero,
Zero padding the signal to increase the resolution in the frequency domain.
Doing FFT to convert the interference signal from scanning distance to spatial frequency domain ( um to rad/um).
Filtering out the interested domain ( my light source is 380 nm to 780 nm, so I only care about the range from 8 ~ 17 rad/um).
Calculating and unwrapping the phase from the filtered result.
Compensating the phase with the phase error calculated by material properties.
Doing IFFT with the compensated phase to convert it back to an interference signa
Figure 1. Original phase from interferogram.
Figure 2. Calculated phase error.
The problem is the wavenumber range of the interference signal is 0 to ~ 25 rad/um while the phase error I calculated only supports from 6~30 rad/um. I would like to know if there are any ways to take out entirely then wavenumber range from 8 ~17 rad/um and do the rest of my work on this range. I also shared my code and raw data here.
Thank you all for reading my problem. Hope you guys have a nice weekend. Hello. I am currently dealing with the interference signal from the Coherence Scanning interferometer. My plan for processing the signal is as follows:
Applying a discriminator to normalize the signal to the center amplitude at zero,
Zero padding the signal to increase the resolution in the frequency domain.
Doing FFT to convert the interference signal from scanning distance to spatial frequency domain ( um to rad/um).
Filtering out the interested domain ( my light source is 380 nm to 780 nm, so I only care about the range from 8 ~ 17 rad/um).
Calculating and unwrapping the phase from the filtered result.
Compensating the phase with the phase error calculated by material properties.
Doing IFFT with the compensated phase to convert it back to an interference signa
Figure 1. Original phase from interferogram.
Figure 2. Calculated phase error.
The problem is the wavenumber range of the interference signal is 0 to ~ 25 rad/um while the phase error I calculated only supports from 6~30 rad/um. I would like to know if there are any ways to take out entirely then wavenumber range from 8 ~17 rad/um and do the rest of my work on this range. I also shared my code and raw data here.
Thank you all for reading my problem. Hope you guys have a nice weekend. fft, signal processing MATLAB Answers — New Questions
Preprocessing PTB-XL dataset in MATLAB
Hello! How can I open specific records from PTB-XL dataset and process them in MATLAB? What I want to do is to first load the ECG leads loaded in .dat file one by one so that I can preprocess them, such as applying digital filters, prior to the creation of composite lead (mixture of 12-lead ECG in one waveform). I have WFDB tool from Physionet. However, it is not working on the dataset. I have the dataset downloaded in my laptop. Thank you!Hello! How can I open specific records from PTB-XL dataset and process them in MATLAB? What I want to do is to first load the ECG leads loaded in .dat file one by one so that I can preprocess them, such as applying digital filters, prior to the creation of composite lead (mixture of 12-lead ECG in one waveform). I have WFDB tool from Physionet. However, it is not working on the dataset. I have the dataset downloaded in my laptop. Thank you! Hello! How can I open specific records from PTB-XL dataset and process them in MATLAB? What I want to do is to first load the ECG leads loaded in .dat file one by one so that I can preprocess them, such as applying digital filters, prior to the creation of composite lead (mixture of 12-lead ECG in one waveform). I have WFDB tool from Physionet. However, it is not working on the dataset. I have the dataset downloaded in my laptop. Thank you! ecg, signal processing, physionet, dataset, wfdb tool MATLAB Answers — New Questions
How do I find the name of the currently-running Matlab LiveScript?
I have a Matlab LiveScript case study which calls many .m functions. At the bottom of the LiveScript, I need to save the results of my case study to a .mat file, and I want the name of the .mat file to be the same as my case study file. For example, if my case study file is named
Case_Something.mlx, then I want the associated results file to be named
Case_Something.mat
I have been relying on the users to change the name of the .mat file for each case they create, but if they forget, they overwrite someone else’s .mat file. If I can recover the name "Case_Something" from the .mlx filename runnning, I can make this automatic. All descriptions of how to do this are examples for .m files, not LiveScripts, and the solutions don’t work.
Is there a way to do this with LiveScripts?
Thanks for any help.I have a Matlab LiveScript case study which calls many .m functions. At the bottom of the LiveScript, I need to save the results of my case study to a .mat file, and I want the name of the .mat file to be the same as my case study file. For example, if my case study file is named
Case_Something.mlx, then I want the associated results file to be named
Case_Something.mat
I have been relying on the users to change the name of the .mat file for each case they create, but if they forget, they overwrite someone else’s .mat file. If I can recover the name "Case_Something" from the .mlx filename runnning, I can make this automatic. All descriptions of how to do this are examples for .m files, not LiveScripts, and the solutions don’t work.
Is there a way to do this with LiveScripts?
Thanks for any help. I have a Matlab LiveScript case study which calls many .m functions. At the bottom of the LiveScript, I need to save the results of my case study to a .mat file, and I want the name of the .mat file to be the same as my case study file. For example, if my case study file is named
Case_Something.mlx, then I want the associated results file to be named
Case_Something.mat
I have been relying on the users to change the name of the .mat file for each case they create, but if they forget, they overwrite someone else’s .mat file. If I can recover the name "Case_Something" from the .mlx filename runnning, I can make this automatic. All descriptions of how to do this are examples for .m files, not LiveScripts, and the solutions don’t work.
Is there a way to do this with LiveScripts?
Thanks for any help. live script, filename, running, save, with same name as MATLAB Answers — New Questions
how can we calculate surface area for this leaf in matlab?
<</matlabcentral/answers/uploaded_files/10685/images.jpg>>
only the leaf<</matlabcentral/answers/uploaded_files/10685/images.jpg>>
only the leaf <</matlabcentral/answers/uploaded_files/10685/images.jpg>>
only the leaf image segmentation, color segmentation, leaf MATLAB Answers — New Questions
MATLAB Web App: Multiple Page survey
I’m trying to make a GUI that takes in answers from multiple study participants. In the GUI, I want the participants to rate multiple audio files based on different questions. I’ve built a basic GUI in App Designer for rating one audio file (with placeholder question titles) and I want it to go to another page with the same structure for rating the subsequent audio files.
I’m a newcomer to MATLAB and needed some pointers on how I could do this. Would I need to create multiple .mlapp for all the audio files and somehow connect them as web apps? I don’t have any experience with working with web servers and databases, so I’m not sure how I would go about in deploying this app for collecting data. Ideally, I would like participants to answer the questions for all audio files (while keeping them anonymous) and save all their responses to a server in form of an excel sheet.
I’ve attached the basic look of the GUI (only for 1 audio) as a screenshot below.I’m trying to make a GUI that takes in answers from multiple study participants. In the GUI, I want the participants to rate multiple audio files based on different questions. I’ve built a basic GUI in App Designer for rating one audio file (with placeholder question titles) and I want it to go to another page with the same structure for rating the subsequent audio files.
I’m a newcomer to MATLAB and needed some pointers on how I could do this. Would I need to create multiple .mlapp for all the audio files and somehow connect them as web apps? I don’t have any experience with working with web servers and databases, so I’m not sure how I would go about in deploying this app for collecting data. Ideally, I would like participants to answer the questions for all audio files (while keeping them anonymous) and save all their responses to a server in form of an excel sheet.
I’ve attached the basic look of the GUI (only for 1 audio) as a screenshot below. I’m trying to make a GUI that takes in answers from multiple study participants. In the GUI, I want the participants to rate multiple audio files based on different questions. I’ve built a basic GUI in App Designer for rating one audio file (with placeholder question titles) and I want it to go to another page with the same structure for rating the subsequent audio files.
I’m a newcomer to MATLAB and needed some pointers on how I could do this. Would I need to create multiple .mlapp for all the audio files and somehow connect them as web apps? I don’t have any experience with working with web servers and databases, so I’m not sure how I would go about in deploying this app for collecting data. Ideally, I would like participants to answer the questions for all audio files (while keeping them anonymous) and save all their responses to a server in form of an excel sheet.
I’ve attached the basic look of the GUI (only for 1 audio) as a screenshot below. database, appdesigner MATLAB Answers — New Questions
Error in server block that is connected to entity generator containing bus elements.
Dear Matlab Experts,
I am having troubles with my model, right now I have designed a model to emulate a single part that goes through operations and maintenance procedures. I am utilizing bus elements in an entity generator, however upon initializing them (file initialize.m) and importing the file directly (file BusProfile.mat), and setting an initial value for each element used in the entity generator tab event actions, I am still encountering this error:
Error in ‘ModelV1/LoadStress’ block. See Service complete action line 15, column 9.
Caused by: This structure does not have a field ‘Missions’; new fields cannot be added when structure has been read or used.
Component:Simulink | Category:Block error
And this error persists for every element that is listed. Any ideas why this happens? I have checked everything up to looking for typos and I am unable to see what is the problem.
Thank you in advance.Dear Matlab Experts,
I am having troubles with my model, right now I have designed a model to emulate a single part that goes through operations and maintenance procedures. I am utilizing bus elements in an entity generator, however upon initializing them (file initialize.m) and importing the file directly (file BusProfile.mat), and setting an initial value for each element used in the entity generator tab event actions, I am still encountering this error:
Error in ‘ModelV1/LoadStress’ block. See Service complete action line 15, column 9.
Caused by: This structure does not have a field ‘Missions’; new fields cannot be added when structure has been read or used.
Component:Simulink | Category:Block error
And this error persists for every element that is listed. Any ideas why this happens? I have checked everything up to looking for typos and I am unable to see what is the problem.
Thank you in advance. Dear Matlab Experts,
I am having troubles with my model, right now I have designed a model to emulate a single part that goes through operations and maintenance procedures. I am utilizing bus elements in an entity generator, however upon initializing them (file initialize.m) and importing the file directly (file BusProfile.mat), and setting an initial value for each element used in the entity generator tab event actions, I am still encountering this error:
Error in ‘ModelV1/LoadStress’ block. See Service complete action line 15, column 9.
Caused by: This structure does not have a field ‘Missions’; new fields cannot be added when structure has been read or used.
Component:Simulink | Category:Block error
And this error persists for every element that is listed. Any ideas why this happens? I have checked everything up to looking for typos and I am unable to see what is the problem.
Thank you in advance. simulink, matlab MATLAB Answers — New Questions
validate arguments stop implicit expansion
classdef Car
properties
id
position
end
methods
function obj = Car(id, position)
arguments
id (1,1) {mustBeNumeric, mustBePositive, mustBeInteger, mustBeNonempty}
position (1,3) double {mustBeVector, mustBeNonempty}
end
obj.id = id;
obj.position = position;
end
end
end
myCar = Car(42, 20)
Instantiation of myCar creates position vector [20, 20, 20]. This is because of implicity expansion. I am trying to stop this by adding a custom validator, but having trouble.classdef Car
properties
id
position
end
methods
function obj = Car(id, position)
arguments
id (1,1) {mustBeNumeric, mustBePositive, mustBeInteger, mustBeNonempty}
position (1,3) double {mustBeVector, mustBeNonempty}
end
obj.id = id;
obj.position = position;
end
end
end
myCar = Car(42, 20)
Instantiation of myCar creates position vector [20, 20, 20]. This is because of implicity expansion. I am trying to stop this by adding a custom validator, but having trouble. classdef Car
properties
id
position
end
methods
function obj = Car(id, position)
arguments
id (1,1) {mustBeNumeric, mustBePositive, mustBeInteger, mustBeNonempty}
position (1,3) double {mustBeVector, mustBeNonempty}
end
obj.id = id;
obj.position = position;
end
end
end
myCar = Car(42, 20)
Instantiation of myCar creates position vector [20, 20, 20]. This is because of implicity expansion. I am trying to stop this by adding a custom validator, but having trouble. implicit expansion validation MATLAB Answers — New Questions
Solving 5 equations (time domain)
<</matlabcentral/answers/uploaded_files/1733763/CamScanner%2007-12-2024%2020.57_01.jpg>>
Can some body write a code to solve these equations ? These are kcl equations in a circuits .
F1(n)=Cg*((Vi(n)-Vi(n-1))/ts)-Cg*((Vg(n)-Vg(n-1))/ts)+(1/R1)*(Vi(n)-Vs(n));
F2(n)=(Cg)*((Vg(n)+Vg(n-2)-2*Vg(n-1))/ts^2)-Cg*((Vi(n)+Vi(n-2)-2*Vi(n-1))/ts^2)+(1/Lg)*(Vg(n)-Vgg)+(1/L1)*(Vg(n)-Vgs(n));
F3(n)=(Cgs(n)+C1)*((Vgs(n)+Vgs(n-2)-2*Vgs(n-1))/ts^2)+(1/L1)*(Vgs(n)-Vg(n))+((Cgs(n)-Cgs(n-1))/ts)*((Vgs(n)-Vgs(n-1))/ts);
F4(n)=(1/Ld)*(Vds(n)-Vdd)+(Cd)*((Vds(n)+Vds(n-2)-2*Vds(n-1))/ts^2)-(Cd)*((Vo(n)+Vo(n-2)-2*Vo(n-1))/ts^2)+((Ids(n)-Ids(n-1))/ts);
F5(n)=Cd*((Vo(n)-Vo(n-1))/(ts))+(Vds(n)-Vds(n-1))/ts;<</matlabcentral/answers/uploaded_files/1733763/CamScanner%2007-12-2024%2020.57_01.jpg>>
Can some body write a code to solve these equations ? These are kcl equations in a circuits .
F1(n)=Cg*((Vi(n)-Vi(n-1))/ts)-Cg*((Vg(n)-Vg(n-1))/ts)+(1/R1)*(Vi(n)-Vs(n));
F2(n)=(Cg)*((Vg(n)+Vg(n-2)-2*Vg(n-1))/ts^2)-Cg*((Vi(n)+Vi(n-2)-2*Vi(n-1))/ts^2)+(1/Lg)*(Vg(n)-Vgg)+(1/L1)*(Vg(n)-Vgs(n));
F3(n)=(Cgs(n)+C1)*((Vgs(n)+Vgs(n-2)-2*Vgs(n-1))/ts^2)+(1/L1)*(Vgs(n)-Vg(n))+((Cgs(n)-Cgs(n-1))/ts)*((Vgs(n)-Vgs(n-1))/ts);
F4(n)=(1/Ld)*(Vds(n)-Vdd)+(Cd)*((Vds(n)+Vds(n-2)-2*Vds(n-1))/ts^2)-(Cd)*((Vo(n)+Vo(n-2)-2*Vo(n-1))/ts^2)+((Ids(n)-Ids(n-1))/ts);
F5(n)=Cd*((Vo(n)-Vo(n-1))/(ts))+(Vds(n)-Vds(n-1))/ts; <</matlabcentral/answers/uploaded_files/1733763/CamScanner%2007-12-2024%2020.57_01.jpg>>
Can some body write a code to solve these equations ? These are kcl equations in a circuits .
F1(n)=Cg*((Vi(n)-Vi(n-1))/ts)-Cg*((Vg(n)-Vg(n-1))/ts)+(1/R1)*(Vi(n)-Vs(n));
F2(n)=(Cg)*((Vg(n)+Vg(n-2)-2*Vg(n-1))/ts^2)-Cg*((Vi(n)+Vi(n-2)-2*Vi(n-1))/ts^2)+(1/Lg)*(Vg(n)-Vgg)+(1/L1)*(Vg(n)-Vgs(n));
F3(n)=(Cgs(n)+C1)*((Vgs(n)+Vgs(n-2)-2*Vgs(n-1))/ts^2)+(1/L1)*(Vgs(n)-Vg(n))+((Cgs(n)-Cgs(n-1))/ts)*((Vgs(n)-Vgs(n-1))/ts);
F4(n)=(1/Ld)*(Vds(n)-Vdd)+(Cd)*((Vds(n)+Vds(n-2)-2*Vds(n-1))/ts^2)-(Cd)*((Vo(n)+Vo(n-2)-2*Vo(n-1))/ts^2)+((Ids(n)-Ids(n-1))/ts);
F5(n)=Cd*((Vo(n)-Vo(n-1))/(ts))+(Vds(n)-Vds(n-1))/ts; time domain solution in matlab MATLAB Answers — New Questions
Keyboard input is not working in Matlab GUIs on Ubuntu 18.04
Hello Matlab Community,
recently I installed Matlab2018a on my Ubuntu 18.04. After the installation was completed I tried to open Matlab GUIs but it did not work. I followed following instructions:
—
cd /usr/local/MATLAB/R2017b
cd cefclient/sys/os/glnxa64
mkdir exclude
mv libglib-2.0.so* exclude/
—
Afterwards I was able to open Matlab GUIs as e.g. Appdesigner, Simulink or the Log In window.
Unfortunately its not possible to make keyboard inputs neither to ‘Edit Fields’ nor to the appdesigner code editor. Summarized: Keyboard inputs in any matlab gui are effectless. Does anybody know a solution?
I look forward to your suggestions.
regards
NilsHello Matlab Community,
recently I installed Matlab2018a on my Ubuntu 18.04. After the installation was completed I tried to open Matlab GUIs but it did not work. I followed following instructions:
—
cd /usr/local/MATLAB/R2017b
cd cefclient/sys/os/glnxa64
mkdir exclude
mv libglib-2.0.so* exclude/
—
Afterwards I was able to open Matlab GUIs as e.g. Appdesigner, Simulink or the Log In window.
Unfortunately its not possible to make keyboard inputs neither to ‘Edit Fields’ nor to the appdesigner code editor. Summarized: Keyboard inputs in any matlab gui are effectless. Does anybody know a solution?
I look forward to your suggestions.
regards
Nils Hello Matlab Community,
recently I installed Matlab2018a on my Ubuntu 18.04. After the installation was completed I tried to open Matlab GUIs but it did not work. I followed following instructions:
—
cd /usr/local/MATLAB/R2017b
cd cefclient/sys/os/glnxa64
mkdir exclude
mv libglib-2.0.so* exclude/
—
Afterwards I was able to open Matlab GUIs as e.g. Appdesigner, Simulink or the Log In window.
Unfortunately its not possible to make keyboard inputs neither to ‘Edit Fields’ nor to the appdesigner code editor. Summarized: Keyboard inputs in any matlab gui are effectless. Does anybody know a solution?
I look forward to your suggestions.
regards
Nils ubuntu, ubuntu 18.04, matlab gui, matlab 2018a, libglib-2.0, gui, linux MATLAB Answers — New Questions
High BER with comm.RayTracingChannel when MaxNumReflections is Set to 0
Hi,
I’m working on writing a code to evaluate BER using comm.RayTracingChannel. I’m referencing the example "Indoor MIMO-OFDM Communication Link Using Ray Tracing". In this example, when I set MaxNumReflections to 0, allowing only the direct path, the BER comes out to be close to 50%.
I don’t understand why this happens. Realistically, in a chamber LOS environment, measuring BER should result in only a direct path and a very low BER. Why does the example produce such a high BER?
Any insights would be greatly appreciated.
Thanks.Hi,
I’m working on writing a code to evaluate BER using comm.RayTracingChannel. I’m referencing the example "Indoor MIMO-OFDM Communication Link Using Ray Tracing". In this example, when I set MaxNumReflections to 0, allowing only the direct path, the BER comes out to be close to 50%.
I don’t understand why this happens. Realistically, in a chamber LOS environment, measuring BER should result in only a direct path and a very low BER. Why does the example produce such a high BER?
Any insights would be greatly appreciated.
Thanks. Hi,
I’m working on writing a code to evaluate BER using comm.RayTracingChannel. I’m referencing the example "Indoor MIMO-OFDM Communication Link Using Ray Tracing". In this example, when I set MaxNumReflections to 0, allowing only the direct path, the BER comes out to be close to 50%.
I don’t understand why this happens. Realistically, in a chamber LOS environment, measuring BER should result in only a direct path and a very low BER. Why does the example produce such a high BER?
Any insights would be greatly appreciated.
Thanks. # ray tracing, #communication #mimo #ofdm MATLAB Answers — New Questions
Problem connecting reliably to Thingspeak over Ethernet
I have been trying to set up a Feather MO plus Ethernet wing to connect to my Thingspeak account. The project will report temperature, humidity, atmospheric pressure and calculate dew point using a BMP280 sensor board every 60 seconds. I’ve written my own code, I’ve also tried other peoples code, I’ve updated all the libraries. The programs are short and simple and they will run for a while (several hours), then fail. When reporting via the IDE they report -304 or -302 errors first, then -301. When the code runs directly connected to the internet it runs for longer but then fails after a few days.
In my latest attempt I took a Mathworks code example directly from Github and only made minor changes to suit the Thingspeak format that I was sending the data to (see below). This code doesn’t use the BME280 or any other code at all, it is just the Mathworks code. The results were the same, it runs for a few hours then reports –304 (Timeout) a few times then recovers, then -302 (Unexpected fail) and then finally, repeated -301 (Connect fail). I suppose I could work around the issue with a Watch Dog Timer but that shouldn’t be necessary.
I now suspect that the problem may be with my router/modem settings (Arris DG3270A) – an area I know very little about. Can anyone suggest what the problem may be and how to fix it? Thank you.
Michael
/*
WriteMultipleFields
Description: Writes values to fields 1,2,3 and 4 in a single ThingSpeak update every 20 seconds.
Hardware: Arduino Ethernet
!!! IMPORTANT – Modify the secrets.h file for this project with your network connection and ThingSpeak channel details. !!!
Note:
– Requires the Ethernet library
ThingSpeak ( https://www.thingspeak.com ) is an analytic IoT platform service that allows you to aggregate, visualize, and
analyze live data streams in the cloud. Visit https://www.thingspeak.com to sign up for a free account and create a channel.
Documentation for the ThingSpeak Communication Library for Arduino is in the README.md folder where the library was installed.
See https://www.mathworks.com/help/thingspeak/index.html for the full ThingSpeak documentation.
For licensing information, see the accompanying license file.
Copyright 2020, The MathWorks, Inc.
*/
#include <Ethernet.h>
#include "Ethernetsecrets.h"
#include "ThingSpeak.h" // always include thingspeak header file after other header files and custom macros
byte mac[] = SECRET_MAC;
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);
IPAddress myDns(192, 168, 0, 1); //changed to 4 from 1
EthernetClient client;
unsigned long myChannelNumber = SECRET_CH_ID;
const char * myWriteAPIKey = SECRET_WRITE_APIKEY;
// Initialize our values
int number1 = 56;
int number2 = random(20,30);
int number3 = random(900,1000);
int number4 = random(0,20);
void setup() {
Ethernet.init(10); // 10 is for most Arduino Ethernet hardware
Serial.begin(115200); //Initialize serial
// start the Ethernet connection:
Serial.println("Initialize Ethernet with DHCP:");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// Check for Ethernet hardware present
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can’t run without hardware. :(");
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip, myDns);
} else {
Serial.print(" DHCP assigned IP ");
Serial.println(Ethernet.localIP());
}
// give the Ethernet shield a second to initialize:
delay(1000);
ThingSpeak.begin(client); // Initialize ThingSpeak
}
void loop() {
// set the fields with the values
ThingSpeak.setField(1, number1);
ThingSpeak.setField(2, number2);
ThingSpeak.setField(3, number3);
ThingSpeak.setField(4, number4);
// write to the ThingSpeak channel
int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
if(x == 200){
Serial.println("Channel update successful.");
}
else{
Serial.println("Problem updating channel. HTTP error code " + String(x));
}
number1 = 56;
number2 = random(20,30);
number3 = random(900,1000);
number4 = random(0,20);
delay(60000); // Wait 60 seconds to update the channel again
}I have been trying to set up a Feather MO plus Ethernet wing to connect to my Thingspeak account. The project will report temperature, humidity, atmospheric pressure and calculate dew point using a BMP280 sensor board every 60 seconds. I’ve written my own code, I’ve also tried other peoples code, I’ve updated all the libraries. The programs are short and simple and they will run for a while (several hours), then fail. When reporting via the IDE they report -304 or -302 errors first, then -301. When the code runs directly connected to the internet it runs for longer but then fails after a few days.
In my latest attempt I took a Mathworks code example directly from Github and only made minor changes to suit the Thingspeak format that I was sending the data to (see below). This code doesn’t use the BME280 or any other code at all, it is just the Mathworks code. The results were the same, it runs for a few hours then reports –304 (Timeout) a few times then recovers, then -302 (Unexpected fail) and then finally, repeated -301 (Connect fail). I suppose I could work around the issue with a Watch Dog Timer but that shouldn’t be necessary.
I now suspect that the problem may be with my router/modem settings (Arris DG3270A) – an area I know very little about. Can anyone suggest what the problem may be and how to fix it? Thank you.
Michael
/*
WriteMultipleFields
Description: Writes values to fields 1,2,3 and 4 in a single ThingSpeak update every 20 seconds.
Hardware: Arduino Ethernet
!!! IMPORTANT – Modify the secrets.h file for this project with your network connection and ThingSpeak channel details. !!!
Note:
– Requires the Ethernet library
ThingSpeak ( https://www.thingspeak.com ) is an analytic IoT platform service that allows you to aggregate, visualize, and
analyze live data streams in the cloud. Visit https://www.thingspeak.com to sign up for a free account and create a channel.
Documentation for the ThingSpeak Communication Library for Arduino is in the README.md folder where the library was installed.
See https://www.mathworks.com/help/thingspeak/index.html for the full ThingSpeak documentation.
For licensing information, see the accompanying license file.
Copyright 2020, The MathWorks, Inc.
*/
#include <Ethernet.h>
#include "Ethernetsecrets.h"
#include "ThingSpeak.h" // always include thingspeak header file after other header files and custom macros
byte mac[] = SECRET_MAC;
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);
IPAddress myDns(192, 168, 0, 1); //changed to 4 from 1
EthernetClient client;
unsigned long myChannelNumber = SECRET_CH_ID;
const char * myWriteAPIKey = SECRET_WRITE_APIKEY;
// Initialize our values
int number1 = 56;
int number2 = random(20,30);
int number3 = random(900,1000);
int number4 = random(0,20);
void setup() {
Ethernet.init(10); // 10 is for most Arduino Ethernet hardware
Serial.begin(115200); //Initialize serial
// start the Ethernet connection:
Serial.println("Initialize Ethernet with DHCP:");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// Check for Ethernet hardware present
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can’t run without hardware. :(");
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip, myDns);
} else {
Serial.print(" DHCP assigned IP ");
Serial.println(Ethernet.localIP());
}
// give the Ethernet shield a second to initialize:
delay(1000);
ThingSpeak.begin(client); // Initialize ThingSpeak
}
void loop() {
// set the fields with the values
ThingSpeak.setField(1, number1);
ThingSpeak.setField(2, number2);
ThingSpeak.setField(3, number3);
ThingSpeak.setField(4, number4);
// write to the ThingSpeak channel
int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
if(x == 200){
Serial.println("Channel update successful.");
}
else{
Serial.println("Problem updating channel. HTTP error code " + String(x));
}
number1 = 56;
number2 = random(20,30);
number3 = random(900,1000);
number4 = random(0,20);
delay(60000); // Wait 60 seconds to update the channel again
} I have been trying to set up a Feather MO plus Ethernet wing to connect to my Thingspeak account. The project will report temperature, humidity, atmospheric pressure and calculate dew point using a BMP280 sensor board every 60 seconds. I’ve written my own code, I’ve also tried other peoples code, I’ve updated all the libraries. The programs are short and simple and they will run for a while (several hours), then fail. When reporting via the IDE they report -304 or -302 errors first, then -301. When the code runs directly connected to the internet it runs for longer but then fails after a few days.
In my latest attempt I took a Mathworks code example directly from Github and only made minor changes to suit the Thingspeak format that I was sending the data to (see below). This code doesn’t use the BME280 or any other code at all, it is just the Mathworks code. The results were the same, it runs for a few hours then reports –304 (Timeout) a few times then recovers, then -302 (Unexpected fail) and then finally, repeated -301 (Connect fail). I suppose I could work around the issue with a Watch Dog Timer but that shouldn’t be necessary.
I now suspect that the problem may be with my router/modem settings (Arris DG3270A) – an area I know very little about. Can anyone suggest what the problem may be and how to fix it? Thank you.
Michael
/*
WriteMultipleFields
Description: Writes values to fields 1,2,3 and 4 in a single ThingSpeak update every 20 seconds.
Hardware: Arduino Ethernet
!!! IMPORTANT – Modify the secrets.h file for this project with your network connection and ThingSpeak channel details. !!!
Note:
– Requires the Ethernet library
ThingSpeak ( https://www.thingspeak.com ) is an analytic IoT platform service that allows you to aggregate, visualize, and
analyze live data streams in the cloud. Visit https://www.thingspeak.com to sign up for a free account and create a channel.
Documentation for the ThingSpeak Communication Library for Arduino is in the README.md folder where the library was installed.
See https://www.mathworks.com/help/thingspeak/index.html for the full ThingSpeak documentation.
For licensing information, see the accompanying license file.
Copyright 2020, The MathWorks, Inc.
*/
#include <Ethernet.h>
#include "Ethernetsecrets.h"
#include "ThingSpeak.h" // always include thingspeak header file after other header files and custom macros
byte mac[] = SECRET_MAC;
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);
IPAddress myDns(192, 168, 0, 1); //changed to 4 from 1
EthernetClient client;
unsigned long myChannelNumber = SECRET_CH_ID;
const char * myWriteAPIKey = SECRET_WRITE_APIKEY;
// Initialize our values
int number1 = 56;
int number2 = random(20,30);
int number3 = random(900,1000);
int number4 = random(0,20);
void setup() {
Ethernet.init(10); // 10 is for most Arduino Ethernet hardware
Serial.begin(115200); //Initialize serial
// start the Ethernet connection:
Serial.println("Initialize Ethernet with DHCP:");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// Check for Ethernet hardware present
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can’t run without hardware. :(");
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip, myDns);
} else {
Serial.print(" DHCP assigned IP ");
Serial.println(Ethernet.localIP());
}
// give the Ethernet shield a second to initialize:
delay(1000);
ThingSpeak.begin(client); // Initialize ThingSpeak
}
void loop() {
// set the fields with the values
ThingSpeak.setField(1, number1);
ThingSpeak.setField(2, number2);
ThingSpeak.setField(3, number3);
ThingSpeak.setField(4, number4);
// write to the ThingSpeak channel
int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
if(x == 200){
Serial.println("Channel update successful.");
}
else{
Serial.println("Problem updating channel. HTTP error code " + String(x));
}
number1 = 56;
number2 = random(20,30);
number3 = random(900,1000);
number4 = random(0,20);
delay(60000); // Wait 60 seconds to update the channel again
} thingspeak, feather, ethernet wing MATLAB Answers — New Questions
dual solution for skin friction and nusselt number and sheerword number using bvp4c solver: mathematical equations and the code is given in description.
Artical:Unsteady boundary-layer flow and heat transfer of a nanofluid over a permeable stretching/shrinking sheet
here are the mathematical equations:
f^”’+A(ff^”-f^’2 )+f^’+η/2 f^”=0
1/Pr θ^”+(Af+η/2) θ^’+Nbθ^’ φ^’+Nt(θ^’ )^2=0
φ^”+Le(Af+η/2) φ^’+Nt/Nb θ^”=0
boundary conditions:
f(0)=s, f^’ (0)=λ, θ(0)=1,φ(0)=1
f^’ (η)→0,θ(η)→0,φ (η)→0 as η→inf
the code is :
Ibrardual()
function Ibrardual
clc
clear all
Nt=0.5; Nb=0.5; Le=2; Pr=1; alpha=1.5; s=1; A=3;
%% solution in structure form
%First solution
sol = bvpinit(linspace(0,6,10), [0 0 0 0 0 0 0]);
sol1 = bvp4c(@bvpexam2, @bcexam2, sol);
x1 = sol1.x;
y1 = sol1.y;
% Second solution
opts = bvpset(‘stats’,’off’,’RelTol’,1e-10);
sol = bvpinit(linspace(0,5,10), [-1 0 0 0 0 0 0]);
sol2 = bvp4c(@bvpexam2, @bcexam2_dual, sol,opts);
x2 = sol2.x;
y2 = sol2.y;
% Plot both solutions
plot(x1,y1(3,:),’-‘); hold on
plot(x2,y2(3,:),’–‘);
xlabel(‘eta’)
ylabel(‘f`(eta)’)
result1 = A^(-1/2)*y1(3,1)
result2 = A^(-1/2)*y2(3,1)
%%residual of bcs
function res = bcexam2(y0, yinf)
res= [y0(1)-s; y0(2)-alpha; y0(4)-1; y0(6)-1; yinf(2); yinf(4);yinf(6)];
end
function res = bcexam2_dual(y0, yinf)
res= [y0(1)-s; y0(2)-alpha; y0(4)-1; y0(6)-1; yinf(2); yinf(4);yinf(6)];
end
%% first order odes
function ysol = bvpexam2(x,y)
yy1 = -(A*y(1)*y(3)-A*(y(2))^2)-y(2)-(x/2)*y(3);
yy2 = -Pr*(A*y(1)*y(5)+(x/2)*y(5)+Nb*y(5)*y(7)+Nt*(y(5))^2);
yy3 = (-Le*(A*(y(1)*y(7)+(x/2)*y(7)))-(Nt/Nb)*( -Pr*(A*y(1)*y(5)+Nb*y(5)*y(7)+Nt*(y(5))^2)));
ysol = [y(2); y(3); yy1;y(5);yy2;y(7);yy3];
end
endArtical:Unsteady boundary-layer flow and heat transfer of a nanofluid over a permeable stretching/shrinking sheet
here are the mathematical equations:
f^”’+A(ff^”-f^’2 )+f^’+η/2 f^”=0
1/Pr θ^”+(Af+η/2) θ^’+Nbθ^’ φ^’+Nt(θ^’ )^2=0
φ^”+Le(Af+η/2) φ^’+Nt/Nb θ^”=0
boundary conditions:
f(0)=s, f^’ (0)=λ, θ(0)=1,φ(0)=1
f^’ (η)→0,θ(η)→0,φ (η)→0 as η→inf
the code is :
Ibrardual()
function Ibrardual
clc
clear all
Nt=0.5; Nb=0.5; Le=2; Pr=1; alpha=1.5; s=1; A=3;
%% solution in structure form
%First solution
sol = bvpinit(linspace(0,6,10), [0 0 0 0 0 0 0]);
sol1 = bvp4c(@bvpexam2, @bcexam2, sol);
x1 = sol1.x;
y1 = sol1.y;
% Second solution
opts = bvpset(‘stats’,’off’,’RelTol’,1e-10);
sol = bvpinit(linspace(0,5,10), [-1 0 0 0 0 0 0]);
sol2 = bvp4c(@bvpexam2, @bcexam2_dual, sol,opts);
x2 = sol2.x;
y2 = sol2.y;
% Plot both solutions
plot(x1,y1(3,:),’-‘); hold on
plot(x2,y2(3,:),’–‘);
xlabel(‘eta’)
ylabel(‘f`(eta)’)
result1 = A^(-1/2)*y1(3,1)
result2 = A^(-1/2)*y2(3,1)
%%residual of bcs
function res = bcexam2(y0, yinf)
res= [y0(1)-s; y0(2)-alpha; y0(4)-1; y0(6)-1; yinf(2); yinf(4);yinf(6)];
end
function res = bcexam2_dual(y0, yinf)
res= [y0(1)-s; y0(2)-alpha; y0(4)-1; y0(6)-1; yinf(2); yinf(4);yinf(6)];
end
%% first order odes
function ysol = bvpexam2(x,y)
yy1 = -(A*y(1)*y(3)-A*(y(2))^2)-y(2)-(x/2)*y(3);
yy2 = -Pr*(A*y(1)*y(5)+(x/2)*y(5)+Nb*y(5)*y(7)+Nt*(y(5))^2);
yy3 = (-Le*(A*(y(1)*y(7)+(x/2)*y(7)))-(Nt/Nb)*( -Pr*(A*y(1)*y(5)+Nb*y(5)*y(7)+Nt*(y(5))^2)));
ysol = [y(2); y(3); yy1;y(5);yy2;y(7);yy3];
end
end Artical:Unsteady boundary-layer flow and heat transfer of a nanofluid over a permeable stretching/shrinking sheet
here are the mathematical equations:
f^”’+A(ff^”-f^’2 )+f^’+η/2 f^”=0
1/Pr θ^”+(Af+η/2) θ^’+Nbθ^’ φ^’+Nt(θ^’ )^2=0
φ^”+Le(Af+η/2) φ^’+Nt/Nb θ^”=0
boundary conditions:
f(0)=s, f^’ (0)=λ, θ(0)=1,φ(0)=1
f^’ (η)→0,θ(η)→0,φ (η)→0 as η→inf
the code is :
Ibrardual()
function Ibrardual
clc
clear all
Nt=0.5; Nb=0.5; Le=2; Pr=1; alpha=1.5; s=1; A=3;
%% solution in structure form
%First solution
sol = bvpinit(linspace(0,6,10), [0 0 0 0 0 0 0]);
sol1 = bvp4c(@bvpexam2, @bcexam2, sol);
x1 = sol1.x;
y1 = sol1.y;
% Second solution
opts = bvpset(‘stats’,’off’,’RelTol’,1e-10);
sol = bvpinit(linspace(0,5,10), [-1 0 0 0 0 0 0]);
sol2 = bvp4c(@bvpexam2, @bcexam2_dual, sol,opts);
x2 = sol2.x;
y2 = sol2.y;
% Plot both solutions
plot(x1,y1(3,:),’-‘); hold on
plot(x2,y2(3,:),’–‘);
xlabel(‘eta’)
ylabel(‘f`(eta)’)
result1 = A^(-1/2)*y1(3,1)
result2 = A^(-1/2)*y2(3,1)
%%residual of bcs
function res = bcexam2(y0, yinf)
res= [y0(1)-s; y0(2)-alpha; y0(4)-1; y0(6)-1; yinf(2); yinf(4);yinf(6)];
end
function res = bcexam2_dual(y0, yinf)
res= [y0(1)-s; y0(2)-alpha; y0(4)-1; y0(6)-1; yinf(2); yinf(4);yinf(6)];
end
%% first order odes
function ysol = bvpexam2(x,y)
yy1 = -(A*y(1)*y(3)-A*(y(2))^2)-y(2)-(x/2)*y(3);
yy2 = -Pr*(A*y(1)*y(5)+(x/2)*y(5)+Nb*y(5)*y(7)+Nt*(y(5))^2);
yy3 = (-Le*(A*(y(1)*y(7)+(x/2)*y(7)))-(Nt/Nb)*( -Pr*(A*y(1)*y(5)+Nb*y(5)*y(7)+Nt*(y(5))^2)));
ysol = [y(2); y(3); yy1;y(5);yy2;y(7);yy3];
end
end matlab MATLAB Answers — New Questions
Prevent Matlab from updating the legend when saving a figure
I have a figure with a tiled layout and some plots which – because they are partly related – I don’t want to give them all their own legend entry, but rather summarise several plots with one entry. I do this by subsequently changing the legend entries to display several line types, like in this example:
leg = legend([plot1, plot2], {‘Plot1’, ‘Plot2’});
drawnow();
% Update legend
hLegendEntryTop = leg.EntryContainer.NodeChildren(end); % top row of legend
iconSet = hLegendEntryTop.Icon.Transform.Children.Children; % array of icons
% Move primary line up
iconSet(1).VertexData(2,1) = 0.65;
iconSet(1).VertexData(2,2) = 0.65;
% Create a new line
iconSet(2) = copy(iconSet(1)); % copy the object
iconSet(2) = iconSet(1).Parent; % set the parent, adding to the legend’s icon draw set
% Move primary line down
iconSet(2).VertexData(2,1) = 0.35;
iconSet(2).VertexData(2,2) = 0.35;
iconSet(2).LineStyle = ‘dashed’;
…… % Do the same with other plot lines
saveas(gcf,’figure’,’epsc’)
Interestingly, it works when exporting as PNG, but not when exporting as eps or pdf (vector graphics). The image is then updated and all additional lines inserted disappear again. I have absolutely no idea how I can prevent Matlab from updating the legend again when saving.I have a figure with a tiled layout and some plots which – because they are partly related – I don’t want to give them all their own legend entry, but rather summarise several plots with one entry. I do this by subsequently changing the legend entries to display several line types, like in this example:
leg = legend([plot1, plot2], {‘Plot1’, ‘Plot2’});
drawnow();
% Update legend
hLegendEntryTop = leg.EntryContainer.NodeChildren(end); % top row of legend
iconSet = hLegendEntryTop.Icon.Transform.Children.Children; % array of icons
% Move primary line up
iconSet(1).VertexData(2,1) = 0.65;
iconSet(1).VertexData(2,2) = 0.65;
% Create a new line
iconSet(2) = copy(iconSet(1)); % copy the object
iconSet(2) = iconSet(1).Parent; % set the parent, adding to the legend’s icon draw set
% Move primary line down
iconSet(2).VertexData(2,1) = 0.35;
iconSet(2).VertexData(2,2) = 0.35;
iconSet(2).LineStyle = ‘dashed’;
…… % Do the same with other plot lines
saveas(gcf,’figure’,’epsc’)
Interestingly, it works when exporting as PNG, but not when exporting as eps or pdf (vector graphics). The image is then updated and all additional lines inserted disappear again. I have absolutely no idea how I can prevent Matlab from updating the legend again when saving. I have a figure with a tiled layout and some plots which – because they are partly related – I don’t want to give them all their own legend entry, but rather summarise several plots with one entry. I do this by subsequently changing the legend entries to display several line types, like in this example:
leg = legend([plot1, plot2], {‘Plot1’, ‘Plot2’});
drawnow();
% Update legend
hLegendEntryTop = leg.EntryContainer.NodeChildren(end); % top row of legend
iconSet = hLegendEntryTop.Icon.Transform.Children.Children; % array of icons
% Move primary line up
iconSet(1).VertexData(2,1) = 0.65;
iconSet(1).VertexData(2,2) = 0.65;
% Create a new line
iconSet(2) = copy(iconSet(1)); % copy the object
iconSet(2) = iconSet(1).Parent; % set the parent, adding to the legend’s icon draw set
% Move primary line down
iconSet(2).VertexData(2,1) = 0.35;
iconSet(2).VertexData(2,2) = 0.35;
iconSet(2).LineStyle = ‘dashed’;
…… % Do the same with other plot lines
saveas(gcf,’figure’,’epsc’)
Interestingly, it works when exporting as PNG, but not when exporting as eps or pdf (vector graphics). The image is then updated and all additional lines inserted disappear again. I have absolutely no idea how I can prevent Matlab from updating the legend again when saving. save, legend MATLAB Answers — New Questions
What is the autocorrelation of the Gaussian random noise sequence N = 20
What is the autocorrelation of the Gaussian random noise sequence N = 20What is the autocorrelation of the Gaussian random noise sequence N = 20 What is the autocorrelation of the Gaussian random noise sequence N = 20 dsp MATLAB Answers — New Questions
The Output structure of a code is showing different outputs in command window and workspace
When working on a program, after executing it and checking output in MATLAB command window and in output from workspace is giving different outputs. Which is correct output here and what is this happening?
Command window output:
Workspace output:When working on a program, after executing it and checking output in MATLAB command window and in output from workspace is giving different outputs. Which is correct output here and what is this happening?
Command window output:
Workspace output: When working on a program, after executing it and checking output in MATLAB command window and in output from workspace is giving different outputs. Which is correct output here and what is this happening?
Command window output:
Workspace output: output matlab MATLAB Answers — New Questions
I need to connect physical modelling connection port to the output of a switch with 2 input. How can I establish this?
Post Content Post Content multiple source connection MATLAB Answers — New Questions
How to retrieve datas from multiples GUIs into a function ?
Hello everyone !
I have several GUI windows to collect parameters and I want to use them in functions.
The problem is, I store datas from edit text boxes into arrays like that :
typex=getappdata(hObject,’typex’);
typex(end+1)=str2double(handles.typex(1).String);
handles.typex(1).String=sprintf(‘block %d’,numel(typex)+1);
disp(typex)
setappdata(hObject,’typex’,typex);
assignin(‘base’,’typex’,typex);
Then, in a callback I use them in the same GUI:
xw=getappdata(handles.xw(1),’xw’);
xe=getappdata(handles.xe(1),’xe’);
nx=getappdata(handles.nx(1),’nx’);
typex=getappdata(handles.typex(1),’typex’);
%Choix du programme de rafinement a executer
if(typex==1)
n=length(nx);
for i=1:n
xwt=xw(i);
xet=xe(i);
nxt=nx(i);
create_block_uniform_X(xwt, xet, nxt)
end
That does works.
But in an other function, I use that to retrieve the datas:
X=getappdata(0,’X’)
Y=getappdata(0,’Y’)
Z=getappdata(0,’Z’)
nx=getappdata(0,’nx’)
xw=getappdata(0,’xw’)
xe=getappdata(0,’xe’)
ny=getappdata(0,’ny’)
yw=getappdata(0,’yw’)
ye=getappdata(0,’ye’)
nz=getappdata(0,’nz’)
zw=getappdata(0,’zw’)
ze=getappdata(0,’ze’)
The thing is that for X,Y,Z it does retrieve the datas (X, Y, Z are the outputs arguments from the previous fonction ‘create_block_uniform’) but that return empty arrays for the others… I don’t understand
Z =
Columns 1 through 13
0 1.1111 2.2222 3.3333 4.4444 5.5556 6.6667 7.7778 8.8889 10.0000 0 0 0
Columns 14 through 18
0 0 0 0 0
nx =
[]
xw =
[]
xe =
[]
Could someone help me ?
Thanks !Hello everyone !
I have several GUI windows to collect parameters and I want to use them in functions.
The problem is, I store datas from edit text boxes into arrays like that :
typex=getappdata(hObject,’typex’);
typex(end+1)=str2double(handles.typex(1).String);
handles.typex(1).String=sprintf(‘block %d’,numel(typex)+1);
disp(typex)
setappdata(hObject,’typex’,typex);
assignin(‘base’,’typex’,typex);
Then, in a callback I use them in the same GUI:
xw=getappdata(handles.xw(1),’xw’);
xe=getappdata(handles.xe(1),’xe’);
nx=getappdata(handles.nx(1),’nx’);
typex=getappdata(handles.typex(1),’typex’);
%Choix du programme de rafinement a executer
if(typex==1)
n=length(nx);
for i=1:n
xwt=xw(i);
xet=xe(i);
nxt=nx(i);
create_block_uniform_X(xwt, xet, nxt)
end
That does works.
But in an other function, I use that to retrieve the datas:
X=getappdata(0,’X’)
Y=getappdata(0,’Y’)
Z=getappdata(0,’Z’)
nx=getappdata(0,’nx’)
xw=getappdata(0,’xw’)
xe=getappdata(0,’xe’)
ny=getappdata(0,’ny’)
yw=getappdata(0,’yw’)
ye=getappdata(0,’ye’)
nz=getappdata(0,’nz’)
zw=getappdata(0,’zw’)
ze=getappdata(0,’ze’)
The thing is that for X,Y,Z it does retrieve the datas (X, Y, Z are the outputs arguments from the previous fonction ‘create_block_uniform’) but that return empty arrays for the others… I don’t understand
Z =
Columns 1 through 13
0 1.1111 2.2222 3.3333 4.4444 5.5556 6.6667 7.7778 8.8889 10.0000 0 0 0
Columns 14 through 18
0 0 0 0 0
nx =
[]
xw =
[]
xe =
[]
Could someone help me ?
Thanks ! Hello everyone !
I have several GUI windows to collect parameters and I want to use them in functions.
The problem is, I store datas from edit text boxes into arrays like that :
typex=getappdata(hObject,’typex’);
typex(end+1)=str2double(handles.typex(1).String);
handles.typex(1).String=sprintf(‘block %d’,numel(typex)+1);
disp(typex)
setappdata(hObject,’typex’,typex);
assignin(‘base’,’typex’,typex);
Then, in a callback I use them in the same GUI:
xw=getappdata(handles.xw(1),’xw’);
xe=getappdata(handles.xe(1),’xe’);
nx=getappdata(handles.nx(1),’nx’);
typex=getappdata(handles.typex(1),’typex’);
%Choix du programme de rafinement a executer
if(typex==1)
n=length(nx);
for i=1:n
xwt=xw(i);
xet=xe(i);
nxt=nx(i);
create_block_uniform_X(xwt, xet, nxt)
end
That does works.
But in an other function, I use that to retrieve the datas:
X=getappdata(0,’X’)
Y=getappdata(0,’Y’)
Z=getappdata(0,’Z’)
nx=getappdata(0,’nx’)
xw=getappdata(0,’xw’)
xe=getappdata(0,’xe’)
ny=getappdata(0,’ny’)
yw=getappdata(0,’yw’)
ye=getappdata(0,’ye’)
nz=getappdata(0,’nz’)
zw=getappdata(0,’zw’)
ze=getappdata(0,’ze’)
The thing is that for X,Y,Z it does retrieve the datas (X, Y, Z are the outputs arguments from the previous fonction ‘create_block_uniform’) but that return empty arrays for the others… I don’t understand
Z =
Columns 1 through 13
0 1.1111 2.2222 3.3333 4.4444 5.5556 6.6667 7.7778 8.8889 10.0000 0 0 0
Columns 14 through 18
0 0 0 0 0
nx =
[]
xw =
[]
xe =
[]
Could someone help me ?
Thanks ! store data MATLAB Answers — New Questions
Login problems with Matlab 2024a
I keep receiving the message "Unable to save login information. You are currently signed in but you will be prompted to sign in again the next time that you start this application." everytime I start the Matlab application.
I tried to follow all the steps I could find, such as reinstaling the Mathworks Service Host, eliminating the files at ‘%APPDATA%MathWorkscredentials’, ‘%APPDATA%RoamingMathWorksMATLAB’, reinstaling the Matlab 2024a. I don’t know what else to do in order to fix this problem.
Can you help me?I keep receiving the message "Unable to save login information. You are currently signed in but you will be prompted to sign in again the next time that you start this application." everytime I start the Matlab application.
I tried to follow all the steps I could find, such as reinstaling the Mathworks Service Host, eliminating the files at ‘%APPDATA%MathWorkscredentials’, ‘%APPDATA%RoamingMathWorksMATLAB’, reinstaling the Matlab 2024a. I don’t know what else to do in order to fix this problem.
Can you help me? I keep receiving the message "Unable to save login information. You are currently signed in but you will be prompted to sign in again the next time that you start this application." everytime I start the Matlab application.
I tried to follow all the steps I could find, such as reinstaling the Mathworks Service Host, eliminating the files at ‘%APPDATA%MathWorkscredentials’, ‘%APPDATA%RoamingMathWorksMATLAB’, reinstaling the Matlab 2024a. I don’t know what else to do in order to fix this problem.
Can you help me? login, r2024a, credentials MATLAB Answers — New Questions
Error in data size using CIC filter in Simulink R2020b: The number of input rows must be a multiple of the decimation factor
I am trying a simple Simulink model of an NCO generating a sin and cos which I then use in their own respective CIC decimator to generate quad and real output signals.
In the two product blocks (X) I get an error "The number of input rows must be a multiple of the decimation factor". I tried adding the convert blocks and specifying output type fixdt(1,20,18), but that didn’t help. The NCO is generating the proper sin and cos with amplitude +/-1 and frequency 13.5MHz with a 256Mhz sample rate.
What is the trick to getting the CIC to work? I looked at a similar Matlab Example for a GSM dds and it worked, but there was nothing special done (that I could see) to make the CIC input data types correct. Please help, I’ve spent a day chasing this problem :(I am trying a simple Simulink model of an NCO generating a sin and cos which I then use in their own respective CIC decimator to generate quad and real output signals.
In the two product blocks (X) I get an error "The number of input rows must be a multiple of the decimation factor". I tried adding the convert blocks and specifying output type fixdt(1,20,18), but that didn’t help. The NCO is generating the proper sin and cos with amplitude +/-1 and frequency 13.5MHz with a 256Mhz sample rate.
What is the trick to getting the CIC to work? I looked at a similar Matlab Example for a GSM dds and it worked, but there was nothing special done (that I could see) to make the CIC input data types correct. Please help, I’ve spent a day chasing this problem 🙁 I am trying a simple Simulink model of an NCO generating a sin and cos which I then use in their own respective CIC decimator to generate quad and real output signals.
In the two product blocks (X) I get an error "The number of input rows must be a multiple of the decimation factor". I tried adding the convert blocks and specifying output type fixdt(1,20,18), but that didn’t help. The NCO is generating the proper sin and cos with amplitude +/-1 and frequency 13.5MHz with a 256Mhz sample rate.
What is the trick to getting the CIC to work? I looked at a similar Matlab Example for a GSM dds and it worked, but there was nothing special done (that I could see) to make the CIC input data types correct. Please help, I’ve spent a day chasing this problem 🙁 #cic, #simulink MATLAB Answers — New Questions