Category: Matlab
Category Archives: Matlab
the degradation of ozone in aqueous solutions (water). When I plot the all three components, the plot stays at the 0 value for all components.
function ProjectOzone
clc
ki = 7e-3;
kj = 2e-5;
k1 = 1e3;
k2 = 1e3;
k3 = 5e7;
OH = 1e-6;
%constants
t0=0;
tn=1000000;
% time iteration interval is set to a high value to reach steady state
Ca0 = 0.002292;
Cb0 = 0;
Cc0 = 0;
% initial concentrations
[tsoln, Csoln] = ode45(@Ozone,[t0 tn],[Ca0 Cb0 Cc0]);
plot(tsoln, Csoln)
xlabel(‘Time’)
ylabel(‘Concentration’)
legend(‘Cb’)
function dC = Ozone(~, C)
dC = zeros(3,1);
dC(1) = -C(1)*(3*ki + kj*OH + 2*k2*sqrt((C(1)/(2*k3))*(2*ki+kj*OH)));
dC(2) = (2*ki)*C(1) – k1*C(1)*C(2) + k2*C(1)*C(3);
dC(3) = kj*C(1)*OH + k1*C(1)*C(2) – k2*C(1)*C(3) – (2*k3)*(C(3)^2);
end %dC(1) is evaluated by steady state approximation method
end
%HERE IS THE CODE, I POST IT IF YOU WANT TO CHECKfunction ProjectOzone
clc
ki = 7e-3;
kj = 2e-5;
k1 = 1e3;
k2 = 1e3;
k3 = 5e7;
OH = 1e-6;
%constants
t0=0;
tn=1000000;
% time iteration interval is set to a high value to reach steady state
Ca0 = 0.002292;
Cb0 = 0;
Cc0 = 0;
% initial concentrations
[tsoln, Csoln] = ode45(@Ozone,[t0 tn],[Ca0 Cb0 Cc0]);
plot(tsoln, Csoln)
xlabel(‘Time’)
ylabel(‘Concentration’)
legend(‘Cb’)
function dC = Ozone(~, C)
dC = zeros(3,1);
dC(1) = -C(1)*(3*ki + kj*OH + 2*k2*sqrt((C(1)/(2*k3))*(2*ki+kj*OH)));
dC(2) = (2*ki)*C(1) – k1*C(1)*C(2) + k2*C(1)*C(3);
dC(3) = kj*C(1)*OH + k1*C(1)*C(2) – k2*C(1)*C(3) – (2*k3)*(C(3)^2);
end %dC(1) is evaluated by steady state approximation method
end
%HERE IS THE CODE, I POST IT IF YOU WANT TO CHECK function ProjectOzone
clc
ki = 7e-3;
kj = 2e-5;
k1 = 1e3;
k2 = 1e3;
k3 = 5e7;
OH = 1e-6;
%constants
t0=0;
tn=1000000;
% time iteration interval is set to a high value to reach steady state
Ca0 = 0.002292;
Cb0 = 0;
Cc0 = 0;
% initial concentrations
[tsoln, Csoln] = ode45(@Ozone,[t0 tn],[Ca0 Cb0 Cc0]);
plot(tsoln, Csoln)
xlabel(‘Time’)
ylabel(‘Concentration’)
legend(‘Cb’)
function dC = Ozone(~, C)
dC = zeros(3,1);
dC(1) = -C(1)*(3*ki + kj*OH + 2*k2*sqrt((C(1)/(2*k3))*(2*ki+kj*OH)));
dC(2) = (2*ki)*C(1) – k1*C(1)*C(2) + k2*C(1)*C(3);
dC(3) = kj*C(1)*OH + k1*C(1)*C(2) – k2*C(1)*C(3) – (2*k3)*(C(3)^2);
end %dC(1) is evaluated by steady state approximation method
end
%HERE IS THE CODE, I POST IT IF YOU WANT TO CHECK ozone-degradation, mathematical modelling, ode45, plotting, plot MATLAB Answers — New Questions
limiting slider part motion distance of the prismatic joint in simulink
I want to limit the distance of the slider part which slides with a prismatic joint. for example I want it to slide 0.5 m to downward and come back to its initial positionI want to limit the distance of the slider part which slides with a prismatic joint. for example I want it to slide 0.5 m to downward and come back to its initial position I want to limit the distance of the slider part which slides with a prismatic joint. for example I want it to slide 0.5 m to downward and come back to its initial position simulink, simulation, robotic, roboticarm, scara, robot, robotarm MATLAB Answers — New Questions
Neural network for regression task: Circuit modeling
Hi everyone, i’m experimenting with using a DNN for modeling an electrical circuit. I have done many tries and until now i always used one sample for input( sequenceInputLayer(1) ) a one for output( since it is a regression task). Now, since the circuit i am modeling has memory, i would like to try to extend input lenght to count for more input sample at once but keeping my output as one single sample. I am facing problems in this beacuse i have my input_data vector that is 1167×1 so 1 column. This means that sequenceInputLayer expect always 1 as dimension and i am limited to this.
On the other hand i can transpose my vectors and use 1167 as input and output dimension, but I would like more freedom and try for example a NN with an input layer of size 300, then 2 hidden layes with size 50/100 (using tanh ecc..) and then my final output layer with output size 1 ( again, since this is a regression task). I already read MATLAB documentstion but i didn’t find what i am searching for. This is the code i am using now, if you have suggestions i would be really happy!!!
Maybe i have to use mini batches? What changes i have to do in order to realize the network i said before?
(Yes, i know that for dynamical systems with memory CNN and RNN neural nets are better but in literature there are also papaer that use DNN for this type of modeling, i.e. using more input(past sample) in a DNN for taking into account memory effects).
%load Vout.mat %LTspice data
t = (0:5.145e-5:60e-3)’; %creates 1167 samples
input_data=10*sin(200*2*pi*t);
output_data=Vout;
% plot(input_data);hold on
% plot(output_data);
%B = reshape(input_data,[],4); %ottengo numero di colonne specifiche,4
% Creazione della rete neurale profonda
layers = […
sequenceInputLayer(1)
fullyConnectedLayer(10)
reluLayer
%lstmLayer(100)
fullyConnectedLayer(10)
sigmoidLayer
fullyConnectedLayer(10)
tanhLayer
fullyConnectedLayer(1) % Output layer con una sola uscita
%tanhLayer
];
% Creazione della dlnetwork
net = dlnetwork(layers);
% Impostazione delle opzioni di addestramento
options = trainingOptions(‘adam’, …
‘MaxEpochs’,1000,…
‘InitialLearnRate’,1e-2, …
‘Verbose’,false, …
‘Plots’,’training-progress’);
% Addestramento della rete neurale
net = trainnet(input_data, output_data, net,"huber" , options);
%Predict
output_test = predict(net,input_data);Hi everyone, i’m experimenting with using a DNN for modeling an electrical circuit. I have done many tries and until now i always used one sample for input( sequenceInputLayer(1) ) a one for output( since it is a regression task). Now, since the circuit i am modeling has memory, i would like to try to extend input lenght to count for more input sample at once but keeping my output as one single sample. I am facing problems in this beacuse i have my input_data vector that is 1167×1 so 1 column. This means that sequenceInputLayer expect always 1 as dimension and i am limited to this.
On the other hand i can transpose my vectors and use 1167 as input and output dimension, but I would like more freedom and try for example a NN with an input layer of size 300, then 2 hidden layes with size 50/100 (using tanh ecc..) and then my final output layer with output size 1 ( again, since this is a regression task). I already read MATLAB documentstion but i didn’t find what i am searching for. This is the code i am using now, if you have suggestions i would be really happy!!!
Maybe i have to use mini batches? What changes i have to do in order to realize the network i said before?
(Yes, i know that for dynamical systems with memory CNN and RNN neural nets are better but in literature there are also papaer that use DNN for this type of modeling, i.e. using more input(past sample) in a DNN for taking into account memory effects).
%load Vout.mat %LTspice data
t = (0:5.145e-5:60e-3)’; %creates 1167 samples
input_data=10*sin(200*2*pi*t);
output_data=Vout;
% plot(input_data);hold on
% plot(output_data);
%B = reshape(input_data,[],4); %ottengo numero di colonne specifiche,4
% Creazione della rete neurale profonda
layers = […
sequenceInputLayer(1)
fullyConnectedLayer(10)
reluLayer
%lstmLayer(100)
fullyConnectedLayer(10)
sigmoidLayer
fullyConnectedLayer(10)
tanhLayer
fullyConnectedLayer(1) % Output layer con una sola uscita
%tanhLayer
];
% Creazione della dlnetwork
net = dlnetwork(layers);
% Impostazione delle opzioni di addestramento
options = trainingOptions(‘adam’, …
‘MaxEpochs’,1000,…
‘InitialLearnRate’,1e-2, …
‘Verbose’,false, …
‘Plots’,’training-progress’);
% Addestramento della rete neurale
net = trainnet(input_data, output_data, net,"huber" , options);
%Predict
output_test = predict(net,input_data); Hi everyone, i’m experimenting with using a DNN for modeling an electrical circuit. I have done many tries and until now i always used one sample for input( sequenceInputLayer(1) ) a one for output( since it is a regression task). Now, since the circuit i am modeling has memory, i would like to try to extend input lenght to count for more input sample at once but keeping my output as one single sample. I am facing problems in this beacuse i have my input_data vector that is 1167×1 so 1 column. This means that sequenceInputLayer expect always 1 as dimension and i am limited to this.
On the other hand i can transpose my vectors and use 1167 as input and output dimension, but I would like more freedom and try for example a NN with an input layer of size 300, then 2 hidden layes with size 50/100 (using tanh ecc..) and then my final output layer with output size 1 ( again, since this is a regression task). I already read MATLAB documentstion but i didn’t find what i am searching for. This is the code i am using now, if you have suggestions i would be really happy!!!
Maybe i have to use mini batches? What changes i have to do in order to realize the network i said before?
(Yes, i know that for dynamical systems with memory CNN and RNN neural nets are better but in literature there are also papaer that use DNN for this type of modeling, i.e. using more input(past sample) in a DNN for taking into account memory effects).
%load Vout.mat %LTspice data
t = (0:5.145e-5:60e-3)’; %creates 1167 samples
input_data=10*sin(200*2*pi*t);
output_data=Vout;
% plot(input_data);hold on
% plot(output_data);
%B = reshape(input_data,[],4); %ottengo numero di colonne specifiche,4
% Creazione della rete neurale profonda
layers = […
sequenceInputLayer(1)
fullyConnectedLayer(10)
reluLayer
%lstmLayer(100)
fullyConnectedLayer(10)
sigmoidLayer
fullyConnectedLayer(10)
tanhLayer
fullyConnectedLayer(1) % Output layer con una sola uscita
%tanhLayer
];
% Creazione della dlnetwork
net = dlnetwork(layers);
% Impostazione delle opzioni di addestramento
options = trainingOptions(‘adam’, …
‘MaxEpochs’,1000,…
‘InitialLearnRate’,1e-2, …
‘Verbose’,false, …
‘Plots’,’training-progress’);
% Addestramento della rete neurale
net = trainnet(input_data, output_data, net,"huber" , options);
%Predict
output_test = predict(net,input_data); neural networks, circuit modeling, feedforward neural networks MATLAB Answers — New Questions
Inconsistent code generation of Block parameters with Embedded Coder
I’m trying to generate C++ code via Embedded Coder.
This simple model contains some variables a,b,b1, where their constant values are implicitly set under .mat file
#
This is one of the block parameters:
When I generate code, I get the following
// Parameters (default storage)
struct P_controller_module_T {
double a; // Variable: a
// Referenced by: ‘<Root>/a’
double b; // Variable: b
// Referenced by: ‘<Root>/b’
double b1; // Variable: b1
// Referenced by: ‘<Root>/b1’
};
However in another model I have the following block parameters (constant values are also implicitly set under .mat files) :
But when generating code I get the following :
double Kp_lat_Value; // Expression: Kp_lat
// Referenced by: ‘<S11>/Kp_lat’
How do I keep the suffix "_Value" consistent ?I’m trying to generate C++ code via Embedded Coder.
This simple model contains some variables a,b,b1, where their constant values are implicitly set under .mat file
#
This is one of the block parameters:
When I generate code, I get the following
// Parameters (default storage)
struct P_controller_module_T {
double a; // Variable: a
// Referenced by: ‘<Root>/a’
double b; // Variable: b
// Referenced by: ‘<Root>/b’
double b1; // Variable: b1
// Referenced by: ‘<Root>/b1’
};
However in another model I have the following block parameters (constant values are also implicitly set under .mat files) :
But when generating code I get the following :
double Kp_lat_Value; // Expression: Kp_lat
// Referenced by: ‘<S11>/Kp_lat’
How do I keep the suffix "_Value" consistent ? I’m trying to generate C++ code via Embedded Coder.
This simple model contains some variables a,b,b1, where their constant values are implicitly set under .mat file
#
This is one of the block parameters:
When I generate code, I get the following
// Parameters (default storage)
struct P_controller_module_T {
double a; // Variable: a
// Referenced by: ‘<Root>/a’
double b; // Variable: b
// Referenced by: ‘<Root>/b’
double b1; // Variable: b1
// Referenced by: ‘<Root>/b1’
};
However in another model I have the following block parameters (constant values are also implicitly set under .mat files) :
But when generating code I get the following :
double Kp_lat_Value; // Expression: Kp_lat
// Referenced by: ‘<S11>/Kp_lat’
How do I keep the suffix "_Value" consistent ? embedded coder, simulink, c++ MATLAB Answers — New Questions
Virtual synchronous machine (simulink file)
Hi, I’m doing a research about appliying virtual synchronous machine in tidal energy.
Do anyone has a simulink model of Virtual Synchronous Machine (VSM)?
Many thanks.Hi, I’m doing a research about appliying virtual synchronous machine in tidal energy.
Do anyone has a simulink model of Virtual Synchronous Machine (VSM)?
Many thanks. Hi, I’m doing a research about appliying virtual synchronous machine in tidal energy.
Do anyone has a simulink model of Virtual Synchronous Machine (VSM)?
Many thanks. virtual synchronous generator MATLAB Answers — New Questions
How can one use a variable to set color of a line plot , and use colorbar?
Dear MAtLab community,
I am creating a simple line plot, and I would like to use a third variable to color the line at every point .
the line comes as:
line(koordmean(:,1),koordmean(:,2))
xlim([1 640])
ylim([1 480])
set(gca,’ydir’,’reverse’)
and the line should be colouread according to the variable ‘anx’. It should work similar to the imagesc function combined with the colorbar function.
Any suggestions are highly appreciated! Kind regards
lgDear MAtLab community,
I am creating a simple line plot, and I would like to use a third variable to color the line at every point .
the line comes as:
line(koordmean(:,1),koordmean(:,2))
xlim([1 640])
ylim([1 480])
set(gca,’ydir’,’reverse’)
and the line should be colouread according to the variable ‘anx’. It should work similar to the imagesc function combined with the colorbar function.
Any suggestions are highly appreciated! Kind regards
lg Dear MAtLab community,
I am creating a simple line plot, and I would like to use a third variable to color the line at every point .
the line comes as:
line(koordmean(:,1),koordmean(:,2))
xlim([1 640])
ylim([1 480])
set(gca,’ydir’,’reverse’)
and the line should be colouread according to the variable ‘anx’. It should work similar to the imagesc function combined with the colorbar function.
Any suggestions are highly appreciated! Kind regards
lg line plot, imagesc, colorbar MATLAB Answers — New Questions
How can I restart the optimization in “Optimize Live Editor”?
I am new in use of MATLAB_. I want to do a nonlinear optimization with genetic algorithm in Solver-based application. My problem is that I failed, but if I start again, it still includes the things and choices I entered before. How can I start with a clean sheet?I am new in use of MATLAB_. I want to do a nonlinear optimization with genetic algorithm in Solver-based application. My problem is that I failed, but if I start again, it still includes the things and choices I entered before. How can I start with a clean sheet? I am new in use of MATLAB_. I want to do a nonlinear optimization with genetic algorithm in Solver-based application. My problem is that I failed, but if I start again, it still includes the things and choices I entered before. How can I start with a clean sheet? use optimize leve editor task MATLAB Answers — New Questions
Error using sdo.SimulationTest/sim
Hello everyone, i’m having an issue with an application, using AppDesigner, but after deployment only.
In the log file, I can find:
Error using sdo.SimulationTest/sim
Unrecognized function or variable ‘private_sl_CPUInfo’.
sim() is called in a sdo.optimize loop in a annonymous function and I don’t understand at all what could cause the issue, and the application is running fine before deployement (in the AppDesigner).
Does anybody already had this issue or knows something about it?Hello everyone, i’m having an issue with an application, using AppDesigner, but after deployment only.
In the log file, I can find:
Error using sdo.SimulationTest/sim
Unrecognized function or variable ‘private_sl_CPUInfo’.
sim() is called in a sdo.optimize loop in a annonymous function and I don’t understand at all what could cause the issue, and the application is running fine before deployement (in the AppDesigner).
Does anybody already had this issue or knows something about it? Hello everyone, i’m having an issue with an application, using AppDesigner, but after deployment only.
In the log file, I can find:
Error using sdo.SimulationTest/sim
Unrecognized function or variable ‘private_sl_CPUInfo’.
sim() is called in a sdo.optimize loop in a annonymous function and I don’t understand at all what could cause the issue, and the application is running fine before deployement (in the AppDesigner).
Does anybody already had this issue or knows something about it? appdesigner, simulink, simscape, simulation MATLAB Answers — New Questions
How to get rid of the error: Error using horzcat. Dimensions of matrices being concatenated are not consistent
Post Content Post Content horzcat MATLAB Answers — New Questions
Mathematics relationship between CDL channels and Saleh-Valenzuela model
Hi everyone,
I’m learning to generate a CDL channel through example CDL Channel Model Customization with Ray Tracing, and I also read some papers about Saleh-Valenzuela model for mmWave, and I see they have some things in common, like AoA, AoD,… But I didn’t find any Matlab source explaining the mathematics behind the functions related to nrCDLChannel() object.
I am wondering if CDL channel use the Saleh-Valenzuela model? Could you please give me some Matlab sites that explain the mathematical formulas behind that? because I saw different papers have different notations of Saleh-Valenzuela model, and it quite confusing for me as a new learner.
Thanks a lot in advance.Hi everyone,
I’m learning to generate a CDL channel through example CDL Channel Model Customization with Ray Tracing, and I also read some papers about Saleh-Valenzuela model for mmWave, and I see they have some things in common, like AoA, AoD,… But I didn’t find any Matlab source explaining the mathematics behind the functions related to nrCDLChannel() object.
I am wondering if CDL channel use the Saleh-Valenzuela model? Could you please give me some Matlab sites that explain the mathematical formulas behind that? because I saw different papers have different notations of Saleh-Valenzuela model, and it quite confusing for me as a new learner.
Thanks a lot in advance. Hi everyone,
I’m learning to generate a CDL channel through example CDL Channel Model Customization with Ray Tracing, and I also read some papers about Saleh-Valenzuela model for mmWave, and I see they have some things in common, like AoA, AoD,… But I didn’t find any Matlab source explaining the mathematics behind the functions related to nrCDLChannel() object.
I am wondering if CDL channel use the Saleh-Valenzuela model? Could you please give me some Matlab sites that explain the mathematical formulas behind that? because I saw different papers have different notations of Saleh-Valenzuela model, and it quite confusing for me as a new learner.
Thanks a lot in advance. cdl channel, saleh-valenzuela, channel model, multi-antenna MATLAB Answers — New Questions
Cant use nested bus objects with bus object arrays in simulink
Hello,
I am trying to build a Bus (struct) (<Quiver>) that has an array of a nested bus type (<Arrow>). Later, I want to dissect this array (<arrows>), loop over it and use the members (<point>, <head>) of that bus object.
However, I get the following error:
Selected signal ‘arrows.origin.x’ in the Bus Selector block ‘Demo/Inport’ is invalid since it refers to a bus element within an array of sub-buses. The path to the array of sub-buses is ‘arrows’. Please select the appropriate array element using a Selector block before using the Bus Selector block to access an element within the bus.
This is very annoying. Programatically this is totally normal, nested stucts. Why can I specify the dimension of that struct array, if it wont compile?
How can I do what I intend to do?
This is what I am doing, basically:Hello,
I am trying to build a Bus (struct) (<Quiver>) that has an array of a nested bus type (<Arrow>). Later, I want to dissect this array (<arrows>), loop over it and use the members (<point>, <head>) of that bus object.
However, I get the following error:
Selected signal ‘arrows.origin.x’ in the Bus Selector block ‘Demo/Inport’ is invalid since it refers to a bus element within an array of sub-buses. The path to the array of sub-buses is ‘arrows’. Please select the appropriate array element using a Selector block before using the Bus Selector block to access an element within the bus.
This is very annoying. Programatically this is totally normal, nested stucts. Why can I specify the dimension of that struct array, if it wont compile?
How can I do what I intend to do?
This is what I am doing, basically: Hello,
I am trying to build a Bus (struct) (<Quiver>) that has an array of a nested bus type (<Arrow>). Later, I want to dissect this array (<arrows>), loop over it and use the members (<point>, <head>) of that bus object.
However, I get the following error:
Selected signal ‘arrows.origin.x’ in the Bus Selector block ‘Demo/Inport’ is invalid since it refers to a bus element within an array of sub-buses. The path to the array of sub-buses is ‘arrows’. Please select the appropriate array element using a Selector block before using the Bus Selector block to access an element within the bus.
This is very annoying. Programatically this is totally normal, nested stucts. Why can I specify the dimension of that struct array, if it wont compile?
How can I do what I intend to do?
This is what I am doing, basically: array, bus, simulink, matlab, error MATLAB Answers — New Questions
How to enable required buttons and plot linear fit from group of graphs
I have created an where i want to enable required buttons based on the input given. I have the maxium limit of the required buttons. My app tells about the mangoes quantity in the basket and the plot are made for the estimation of the ripeness of mangoes. Where i have known about the maximum number of mangoes in basket. What i required is, 1) if i change my input, i don’t want the import excel buttons to be deleted instead those should be diabled. 2) After plotting the graphs, i want to make the linear fit and the squareroot fit to the plotted group of graphs. i have attached my app and the excel file for the plot.I have created an where i want to enable required buttons based on the input given. I have the maxium limit of the required buttons. My app tells about the mangoes quantity in the basket and the plot are made for the estimation of the ripeness of mangoes. Where i have known about the maximum number of mangoes in basket. What i required is, 1) if i change my input, i don’t want the import excel buttons to be deleted instead those should be diabled. 2) After plotting the graphs, i want to make the linear fit and the squareroot fit to the plotted group of graphs. i have attached my app and the excel file for the plot. I have created an where i want to enable required buttons based on the input given. I have the maxium limit of the required buttons. My app tells about the mangoes quantity in the basket and the plot are made for the estimation of the ripeness of mangoes. Where i have known about the maximum number of mangoes in basket. What i required is, 1) if i change my input, i don’t want the import excel buttons to be deleted instead those should be diabled. 2) After plotting the graphs, i want to make the linear fit and the squareroot fit to the plotted group of graphs. i have attached my app and the excel file for the plot. matlab, appdesigner MATLAB Answers — New Questions
Issues setting exact sampling rates when using the data acquisition toolbox in MATLAB’s app designer
Hi all,
I have been having issues setting my sampling rate/ DAQ.Rate to the values 2048 and 120. I am using a start function that is set for x amount of seconds. This then triggers the scansavailablecallback and within this callback it will readout about 1 tenth of the values to be graphed out over time. When setting the DAQ’s Rate to 2048 is collects in sample batches of 205, this leaves the sample batch for 0.9s to 1.0s missing 2 samples and does not end up triggering final 0.1s of the callback. I am not too sure why it does this and am wondering if using the scansavailable callback is part of the issue. I have tried to change the DAQ rate for the 0.9-1.0s time to then activate the callback again but this does not seem to work. A similiar issue happens for 120 where it’s sample batch seems to be 13 which I am quite confused by. Any ideas or guidance on how to go about solving these issues would be greatly appreciated.
This is the callback function
function scansAvailable_Callback(app, src, ~)
% Callback function executed on DAQ object ScansAvailable event
% runs after the start button pushed event is complete
if ~isvalid(app)
return
end
disp (app.numscan)
% Read data from the DAQ object
% Read data from the DAQ object
[app.data, timestamps] = read(src,app.DAQ.ScansAvailableFcnCount, ‘OutputFormat’,’Matrix’);
test = [timestamps,app.data];
assignin("base","test",test)
% Calibration
if app.calibrate == true
% sends data to function to be calibrated appropriately
app.calibratedData = calibrateData(app,app.data, app.sl, app.int);
else
% if calibration is not turned off, just take the voltage values
for jj = app.SelectedChannels
app.calibratedData(:,jj) = (app.data(:,jj));
end
end
% checking too put the app back into configuration @ the end of the
% Store continuous acquisition data in FIFO data buffers
buffersize = round(app.DAQ.Rate * app.TimewindowEditField.Value) + 1;
app.TimestampsFIFOBuffer = storeDataInFIFO(app, app.TimestampsFIFOBuffer, buffersize, timestamps);
app.DataFIFOBufferch1 = storeDataInFIFO(app, app.DataFIFOBufferch1, buffersize, app.calibratedData(:,app.SelectedChannels));
% Plotting (Update the plot every N data points received
updatePlotInterval = 1; % Adjust this value based on your preference
if mod(src.ScansAvailableFcnCount, updatePlotInterval) == 0
% runs function that is responsible for plotting a singular
% graph
updateLivePlot(app);
end
% for data that goes to the workspace and
for ii = 1:(round(app.RateEdit.Value/10))
% keep count of the sample#/time
app.fws_x = app.fws_x + 1;
% initialize data to be written into the workspace
app.fwsdata(app.fws_x,(app.SelectedChannels)) = app.calibratedData(ii,app.SelectedChannels);
end
disp(app.fws_x)
if app.ContinuousSwitch.Value == "Off"
lengthcheck = (app.TrialLengthsEditField.Value* app.RateEdit.Value);
disp(lengthcheck)
if app.fws_x >= lengthcheck
if app.LogRequested
try
% Change the data to a timetable
WSData = array2timetable(app.fwsdata(1:app.TrialLengthsEditField.Value*app.DAQ.Rate,app.SelectedChannels),’SampleRate’,app.RateEdit.Value);
varname = table2array(app.UITable.Data(:,1));
% renames the variable names to match the channel names
for i = app.SelectedChannels
WSData = renamevars(WSData,i,varname(i));
end
% write into base workspace with the name stated in the UI
assignin(‘base’, app.VariableNameEditField.Value, WSData);
assignin("base","variable_name",app.VariableNameEditField.Value)
catch exception
uialert(app.LiveDataAcquisitionUIFigure,exception.message,’You cannot start the variable name with a number’)
end
end
setAppViewState(app, ‘configuration’);
end
end
app.numscan = app.numscan + 1;
end
And the following is what initiates the callback
function StartButtonPushed(app, event)
% so the app can go back into "configuration state"
app.fws_x = 0;
app.fwsdata = 0;
app.wstimestamps= 0;
% clearing the graphs just helps with mainly tab 2 when the
% user is switching where a channels goes (between the 2
% graphs)
cla(app.LiveAxes)
if numel(app.SelectedChannels) == 0
warndlg(‘Please select Channels to record’,’No Channels to Record from Selected’)
else
% dur = isinteger(app.DAQ.Rate/10);
% Disable DAQ device, channel properties, and start acquisition UI components
setAppViewState(app, ‘acquisition’);
% Reset FIFO buffer data
app.calibratedData = [];
app.DataFIFOBufferch1 = [];
app.TimestampsFIFOBuffer = [];
% Checks to see if the app is set to continuous or has a the
% User selected to use a recording window instead
if app.continuous == true
% preallocate for the data that is to be written for
% the workspace
app.fwsdata = zeros(400000,numel(app.numchan));
try
% starts data collection
start(app.DAQ,’continuous’);
catch exception
% In case of error show it and revert the change
uialert(app.LiveDataAcquisitionUIFigure, exception.message, ‘Start error, you may have selected channels too quick!’);
setAppViewState(app, ‘configuration’);
end
else
% preallocate for the data that is to be written for
% the workspace based on the trial length and the
% sample rate
app.fwsdata = zeros((app.RateEdit.Value*app.TrialLengthsEditField.Value),numel(app.numchan));
try
start(app.DAQ,"Duration",app.TrialLengthsEditField.Value)
catch exception
% In case of error show it and revert the change
uialert(app.LiveDataAcquisitionUIFigure, exception.message, ‘Start error’);
setAppViewState(app, ‘configuration’);
end
end
% Clear Log status text
app.LogStatusText.Text = ”;
endHi all,
I have been having issues setting my sampling rate/ DAQ.Rate to the values 2048 and 120. I am using a start function that is set for x amount of seconds. This then triggers the scansavailablecallback and within this callback it will readout about 1 tenth of the values to be graphed out over time. When setting the DAQ’s Rate to 2048 is collects in sample batches of 205, this leaves the sample batch for 0.9s to 1.0s missing 2 samples and does not end up triggering final 0.1s of the callback. I am not too sure why it does this and am wondering if using the scansavailable callback is part of the issue. I have tried to change the DAQ rate for the 0.9-1.0s time to then activate the callback again but this does not seem to work. A similiar issue happens for 120 where it’s sample batch seems to be 13 which I am quite confused by. Any ideas or guidance on how to go about solving these issues would be greatly appreciated.
This is the callback function
function scansAvailable_Callback(app, src, ~)
% Callback function executed on DAQ object ScansAvailable event
% runs after the start button pushed event is complete
if ~isvalid(app)
return
end
disp (app.numscan)
% Read data from the DAQ object
% Read data from the DAQ object
[app.data, timestamps] = read(src,app.DAQ.ScansAvailableFcnCount, ‘OutputFormat’,’Matrix’);
test = [timestamps,app.data];
assignin("base","test",test)
% Calibration
if app.calibrate == true
% sends data to function to be calibrated appropriately
app.calibratedData = calibrateData(app,app.data, app.sl, app.int);
else
% if calibration is not turned off, just take the voltage values
for jj = app.SelectedChannels
app.calibratedData(:,jj) = (app.data(:,jj));
end
end
% checking too put the app back into configuration @ the end of the
% Store continuous acquisition data in FIFO data buffers
buffersize = round(app.DAQ.Rate * app.TimewindowEditField.Value) + 1;
app.TimestampsFIFOBuffer = storeDataInFIFO(app, app.TimestampsFIFOBuffer, buffersize, timestamps);
app.DataFIFOBufferch1 = storeDataInFIFO(app, app.DataFIFOBufferch1, buffersize, app.calibratedData(:,app.SelectedChannels));
% Plotting (Update the plot every N data points received
updatePlotInterval = 1; % Adjust this value based on your preference
if mod(src.ScansAvailableFcnCount, updatePlotInterval) == 0
% runs function that is responsible for plotting a singular
% graph
updateLivePlot(app);
end
% for data that goes to the workspace and
for ii = 1:(round(app.RateEdit.Value/10))
% keep count of the sample#/time
app.fws_x = app.fws_x + 1;
% initialize data to be written into the workspace
app.fwsdata(app.fws_x,(app.SelectedChannels)) = app.calibratedData(ii,app.SelectedChannels);
end
disp(app.fws_x)
if app.ContinuousSwitch.Value == "Off"
lengthcheck = (app.TrialLengthsEditField.Value* app.RateEdit.Value);
disp(lengthcheck)
if app.fws_x >= lengthcheck
if app.LogRequested
try
% Change the data to a timetable
WSData = array2timetable(app.fwsdata(1:app.TrialLengthsEditField.Value*app.DAQ.Rate,app.SelectedChannels),’SampleRate’,app.RateEdit.Value);
varname = table2array(app.UITable.Data(:,1));
% renames the variable names to match the channel names
for i = app.SelectedChannels
WSData = renamevars(WSData,i,varname(i));
end
% write into base workspace with the name stated in the UI
assignin(‘base’, app.VariableNameEditField.Value, WSData);
assignin("base","variable_name",app.VariableNameEditField.Value)
catch exception
uialert(app.LiveDataAcquisitionUIFigure,exception.message,’You cannot start the variable name with a number’)
end
end
setAppViewState(app, ‘configuration’);
end
end
app.numscan = app.numscan + 1;
end
And the following is what initiates the callback
function StartButtonPushed(app, event)
% so the app can go back into "configuration state"
app.fws_x = 0;
app.fwsdata = 0;
app.wstimestamps= 0;
% clearing the graphs just helps with mainly tab 2 when the
% user is switching where a channels goes (between the 2
% graphs)
cla(app.LiveAxes)
if numel(app.SelectedChannels) == 0
warndlg(‘Please select Channels to record’,’No Channels to Record from Selected’)
else
% dur = isinteger(app.DAQ.Rate/10);
% Disable DAQ device, channel properties, and start acquisition UI components
setAppViewState(app, ‘acquisition’);
% Reset FIFO buffer data
app.calibratedData = [];
app.DataFIFOBufferch1 = [];
app.TimestampsFIFOBuffer = [];
% Checks to see if the app is set to continuous or has a the
% User selected to use a recording window instead
if app.continuous == true
% preallocate for the data that is to be written for
% the workspace
app.fwsdata = zeros(400000,numel(app.numchan));
try
% starts data collection
start(app.DAQ,’continuous’);
catch exception
% In case of error show it and revert the change
uialert(app.LiveDataAcquisitionUIFigure, exception.message, ‘Start error, you may have selected channels too quick!’);
setAppViewState(app, ‘configuration’);
end
else
% preallocate for the data that is to be written for
% the workspace based on the trial length and the
% sample rate
app.fwsdata = zeros((app.RateEdit.Value*app.TrialLengthsEditField.Value),numel(app.numchan));
try
start(app.DAQ,"Duration",app.TrialLengthsEditField.Value)
catch exception
% In case of error show it and revert the change
uialert(app.LiveDataAcquisitionUIFigure, exception.message, ‘Start error’);
setAppViewState(app, ‘configuration’);
end
end
% Clear Log status text
app.LogStatusText.Text = ”;
end Hi all,
I have been having issues setting my sampling rate/ DAQ.Rate to the values 2048 and 120. I am using a start function that is set for x amount of seconds. This then triggers the scansavailablecallback and within this callback it will readout about 1 tenth of the values to be graphed out over time. When setting the DAQ’s Rate to 2048 is collects in sample batches of 205, this leaves the sample batch for 0.9s to 1.0s missing 2 samples and does not end up triggering final 0.1s of the callback. I am not too sure why it does this and am wondering if using the scansavailable callback is part of the issue. I have tried to change the DAQ rate for the 0.9-1.0s time to then activate the callback again but this does not seem to work. A similiar issue happens for 120 where it’s sample batch seems to be 13 which I am quite confused by. Any ideas or guidance on how to go about solving these issues would be greatly appreciated.
This is the callback function
function scansAvailable_Callback(app, src, ~)
% Callback function executed on DAQ object ScansAvailable event
% runs after the start button pushed event is complete
if ~isvalid(app)
return
end
disp (app.numscan)
% Read data from the DAQ object
% Read data from the DAQ object
[app.data, timestamps] = read(src,app.DAQ.ScansAvailableFcnCount, ‘OutputFormat’,’Matrix’);
test = [timestamps,app.data];
assignin("base","test",test)
% Calibration
if app.calibrate == true
% sends data to function to be calibrated appropriately
app.calibratedData = calibrateData(app,app.data, app.sl, app.int);
else
% if calibration is not turned off, just take the voltage values
for jj = app.SelectedChannels
app.calibratedData(:,jj) = (app.data(:,jj));
end
end
% checking too put the app back into configuration @ the end of the
% Store continuous acquisition data in FIFO data buffers
buffersize = round(app.DAQ.Rate * app.TimewindowEditField.Value) + 1;
app.TimestampsFIFOBuffer = storeDataInFIFO(app, app.TimestampsFIFOBuffer, buffersize, timestamps);
app.DataFIFOBufferch1 = storeDataInFIFO(app, app.DataFIFOBufferch1, buffersize, app.calibratedData(:,app.SelectedChannels));
% Plotting (Update the plot every N data points received
updatePlotInterval = 1; % Adjust this value based on your preference
if mod(src.ScansAvailableFcnCount, updatePlotInterval) == 0
% runs function that is responsible for plotting a singular
% graph
updateLivePlot(app);
end
% for data that goes to the workspace and
for ii = 1:(round(app.RateEdit.Value/10))
% keep count of the sample#/time
app.fws_x = app.fws_x + 1;
% initialize data to be written into the workspace
app.fwsdata(app.fws_x,(app.SelectedChannels)) = app.calibratedData(ii,app.SelectedChannels);
end
disp(app.fws_x)
if app.ContinuousSwitch.Value == "Off"
lengthcheck = (app.TrialLengthsEditField.Value* app.RateEdit.Value);
disp(lengthcheck)
if app.fws_x >= lengthcheck
if app.LogRequested
try
% Change the data to a timetable
WSData = array2timetable(app.fwsdata(1:app.TrialLengthsEditField.Value*app.DAQ.Rate,app.SelectedChannels),’SampleRate’,app.RateEdit.Value);
varname = table2array(app.UITable.Data(:,1));
% renames the variable names to match the channel names
for i = app.SelectedChannels
WSData = renamevars(WSData,i,varname(i));
end
% write into base workspace with the name stated in the UI
assignin(‘base’, app.VariableNameEditField.Value, WSData);
assignin("base","variable_name",app.VariableNameEditField.Value)
catch exception
uialert(app.LiveDataAcquisitionUIFigure,exception.message,’You cannot start the variable name with a number’)
end
end
setAppViewState(app, ‘configuration’);
end
end
app.numscan = app.numscan + 1;
end
And the following is what initiates the callback
function StartButtonPushed(app, event)
% so the app can go back into "configuration state"
app.fws_x = 0;
app.fwsdata = 0;
app.wstimestamps= 0;
% clearing the graphs just helps with mainly tab 2 when the
% user is switching where a channels goes (between the 2
% graphs)
cla(app.LiveAxes)
if numel(app.SelectedChannels) == 0
warndlg(‘Please select Channels to record’,’No Channels to Record from Selected’)
else
% dur = isinteger(app.DAQ.Rate/10);
% Disable DAQ device, channel properties, and start acquisition UI components
setAppViewState(app, ‘acquisition’);
% Reset FIFO buffer data
app.calibratedData = [];
app.DataFIFOBufferch1 = [];
app.TimestampsFIFOBuffer = [];
% Checks to see if the app is set to continuous or has a the
% User selected to use a recording window instead
if app.continuous == true
% preallocate for the data that is to be written for
% the workspace
app.fwsdata = zeros(400000,numel(app.numchan));
try
% starts data collection
start(app.DAQ,’continuous’);
catch exception
% In case of error show it and revert the change
uialert(app.LiveDataAcquisitionUIFigure, exception.message, ‘Start error, you may have selected channels too quick!’);
setAppViewState(app, ‘configuration’);
end
else
% preallocate for the data that is to be written for
% the workspace based on the trial length and the
% sample rate
app.fwsdata = zeros((app.RateEdit.Value*app.TrialLengthsEditField.Value),numel(app.numchan));
try
start(app.DAQ,"Duration",app.TrialLengthsEditField.Value)
catch exception
% In case of error show it and revert the change
uialert(app.LiveDataAcquisitionUIFigure, exception.message, ‘Start error’);
setAppViewState(app, ‘configuration’);
end
end
% Clear Log status text
app.LogStatusText.Text = ”;
end data acquisition, toolbox, graph, callback, appdesigner, app designer MATLAB Answers — New Questions
I Just Want To Read Text From URL And Save It As Txt…. But How?
Hello, Community
I just want to ask about how to read text data from URL and save it as ASCII / .Txt Data. It maybe a simple question for all of you, but it kinda so difficult for me…
So i have a data from URL like this :
2024 05 21 33744 33744.5 2602 4 1.667 1.000 1.000 2.667 2.667 2.333 1.667 1.667 6 4 4 12 12 9 6 6 7 165 190.8 195.4 0 2024 05 22 33745 33745.5 2602 5 1.667 0.667 0.333 0.333 0.000 0.667 1.333 1.333 6 3 2 2 0 3 5 5 3 152 195.7 200.6 0 2024 05 23 33746 33746.5 2602 6 0.667 1.667 1.667 2.333 2.333 1.667 2.333 4.000 3 6 6 9 9 6 9 27 9 134 176.2 180.7 0 2024 05 24 33747 33747.5 2602 7 2.000 3.000 2.667 3.000 2.000 1.333 0.333 1.333 7 15 12 15 7 5 2 5 8 126 162.8 167.0 0 2024 05 25 33748 33748.5 2602 8 1.667 1.333 1.333 0.667 0.667 1.667 1.333 2.333 6 5 5 3 3 6 5 9 5 104 152.4 156.4 0 2024 05 26 33749 33749.5 2602 9 1.333 2.333 1.000 2.000 2.667 2.667 2.667 1.000 5 9 4 7 12 12 12 4 8 120 155.6 159.7 0
Or like this in the image of the source:
The data result of webread function is just like this :
textweb = webread("https://kp.gfz-potsdam.de/kpdata?startdate=2024-05-21&enddate=2024-05-26&format=kp1#kpdatadownload-143");
textweb =
‘2024 05 21 33744 33744.5 2602 4 1.667 1.000 1.000 2.667 2.667 2.333 1.667 1.667 6 4 4 12 12 9 6 6 7 165 190.8 195.4 0
2024 05 22 33745 33745.5 2602 5 1.667 0.667 0.333 0.333 0.000 0.667 1.333 1.333 6 3 2 2 0 3 5 5 3 152 195.7 200.6 0
2024 05 23 33746 33746.5 2602 6 0.667 1.667 1.667 2.333 2.333 1.667 2.333 4.000 3 6 6 9 9 6 9 27 9 134 176.2 180.7 0
2024 05 24 33747 33747.5 2602 7 2.000 3.000 2.667 3.000 2.000 1.333 0.333 1.333 7 15 12 15 7 5 2 5 8 126 162.8 167.0 0
2024 05 25 33748 33748.5 2602 8 1.667 1.333 1.333 0.667 0.667 1.667 1.333 2.333 6 5 5 3 3 6 5 9 5 104 152.4 156.4 0
2024 05 26 33749 33749.5 2602 9 1.333 2.333 1.000 2.000 2.667 2.667 2.667 1.000 5 9 4 7 12 12 12 4 8 120 155.6 159.7 0
‘
And i want to know how to convert the output of webread function above to become a data like this :
"2024 05 21 33744 33744.5 2602 4 1.667 1.000 1.000 2.667 2.667 2.333 1.667 1.667 6 4 4 12 12 9 6 6 7 165 190.8 195.4 0"
"2024 05 22 33745 33745.5 2602 5 1.667 0.667 0.333 0.333 0.000 0.667 1.333 1.333 6 3 2 2 0 3 5 5 3 152 195.7 200.6 0"
"2024 05 23 33746 33746.5 2602 6 0.667 1.667 1.667 2.333 2.333 1.667 2.333 4.000 3 6 6 9 9 6 9 27 9 134 176.2 180.7 0"
"2024 05 24 33747 33747.5 2602 7 2.000 3.000 2.667 3.000 2.000 1.333 0.333 1.333 7 15 12 15 7 5 2 5 8 126 162.8 167.0 0"
"2024 05 25 33748 33748.5 2602 8 1.667 1.333 1.333 0.667 0.667 1.667 1.333 2.333 6 5 5 3 3 6 5 9 5 104 152.4 156.4 0"
"2024 05 26 33749 33749.5 2602 9 1.333 2.333 1.000 2.000 2.667 2.667 2.667 1.000 5 9 4 7 12 12 12 4 8 120 155.6 159.7 0"
OR just simply save the output of webread function to become a txt file (ASCII) which can be opened in my local PC…
Thank you everyone for your attention and cooperation. I would be very grateful if community can help me to solve this problem /. /. /.Hello, Community
I just want to ask about how to read text data from URL and save it as ASCII / .Txt Data. It maybe a simple question for all of you, but it kinda so difficult for me…
So i have a data from URL like this :
2024 05 21 33744 33744.5 2602 4 1.667 1.000 1.000 2.667 2.667 2.333 1.667 1.667 6 4 4 12 12 9 6 6 7 165 190.8 195.4 0 2024 05 22 33745 33745.5 2602 5 1.667 0.667 0.333 0.333 0.000 0.667 1.333 1.333 6 3 2 2 0 3 5 5 3 152 195.7 200.6 0 2024 05 23 33746 33746.5 2602 6 0.667 1.667 1.667 2.333 2.333 1.667 2.333 4.000 3 6 6 9 9 6 9 27 9 134 176.2 180.7 0 2024 05 24 33747 33747.5 2602 7 2.000 3.000 2.667 3.000 2.000 1.333 0.333 1.333 7 15 12 15 7 5 2 5 8 126 162.8 167.0 0 2024 05 25 33748 33748.5 2602 8 1.667 1.333 1.333 0.667 0.667 1.667 1.333 2.333 6 5 5 3 3 6 5 9 5 104 152.4 156.4 0 2024 05 26 33749 33749.5 2602 9 1.333 2.333 1.000 2.000 2.667 2.667 2.667 1.000 5 9 4 7 12 12 12 4 8 120 155.6 159.7 0
Or like this in the image of the source:
The data result of webread function is just like this :
textweb = webread("https://kp.gfz-potsdam.de/kpdata?startdate=2024-05-21&enddate=2024-05-26&format=kp1#kpdatadownload-143");
textweb =
‘2024 05 21 33744 33744.5 2602 4 1.667 1.000 1.000 2.667 2.667 2.333 1.667 1.667 6 4 4 12 12 9 6 6 7 165 190.8 195.4 0
2024 05 22 33745 33745.5 2602 5 1.667 0.667 0.333 0.333 0.000 0.667 1.333 1.333 6 3 2 2 0 3 5 5 3 152 195.7 200.6 0
2024 05 23 33746 33746.5 2602 6 0.667 1.667 1.667 2.333 2.333 1.667 2.333 4.000 3 6 6 9 9 6 9 27 9 134 176.2 180.7 0
2024 05 24 33747 33747.5 2602 7 2.000 3.000 2.667 3.000 2.000 1.333 0.333 1.333 7 15 12 15 7 5 2 5 8 126 162.8 167.0 0
2024 05 25 33748 33748.5 2602 8 1.667 1.333 1.333 0.667 0.667 1.667 1.333 2.333 6 5 5 3 3 6 5 9 5 104 152.4 156.4 0
2024 05 26 33749 33749.5 2602 9 1.333 2.333 1.000 2.000 2.667 2.667 2.667 1.000 5 9 4 7 12 12 12 4 8 120 155.6 159.7 0
‘
And i want to know how to convert the output of webread function above to become a data like this :
"2024 05 21 33744 33744.5 2602 4 1.667 1.000 1.000 2.667 2.667 2.333 1.667 1.667 6 4 4 12 12 9 6 6 7 165 190.8 195.4 0"
"2024 05 22 33745 33745.5 2602 5 1.667 0.667 0.333 0.333 0.000 0.667 1.333 1.333 6 3 2 2 0 3 5 5 3 152 195.7 200.6 0"
"2024 05 23 33746 33746.5 2602 6 0.667 1.667 1.667 2.333 2.333 1.667 2.333 4.000 3 6 6 9 9 6 9 27 9 134 176.2 180.7 0"
"2024 05 24 33747 33747.5 2602 7 2.000 3.000 2.667 3.000 2.000 1.333 0.333 1.333 7 15 12 15 7 5 2 5 8 126 162.8 167.0 0"
"2024 05 25 33748 33748.5 2602 8 1.667 1.333 1.333 0.667 0.667 1.667 1.333 2.333 6 5 5 3 3 6 5 9 5 104 152.4 156.4 0"
"2024 05 26 33749 33749.5 2602 9 1.333 2.333 1.000 2.000 2.667 2.667 2.667 1.000 5 9 4 7 12 12 12 4 8 120 155.6 159.7 0"
OR just simply save the output of webread function to become a txt file (ASCII) which can be opened in my local PC…
Thank you everyone for your attention and cooperation. I would be very grateful if community can help me to solve this problem /. /. /. Hello, Community
I just want to ask about how to read text data from URL and save it as ASCII / .Txt Data. It maybe a simple question for all of you, but it kinda so difficult for me…
So i have a data from URL like this :
2024 05 21 33744 33744.5 2602 4 1.667 1.000 1.000 2.667 2.667 2.333 1.667 1.667 6 4 4 12 12 9 6 6 7 165 190.8 195.4 0 2024 05 22 33745 33745.5 2602 5 1.667 0.667 0.333 0.333 0.000 0.667 1.333 1.333 6 3 2 2 0 3 5 5 3 152 195.7 200.6 0 2024 05 23 33746 33746.5 2602 6 0.667 1.667 1.667 2.333 2.333 1.667 2.333 4.000 3 6 6 9 9 6 9 27 9 134 176.2 180.7 0 2024 05 24 33747 33747.5 2602 7 2.000 3.000 2.667 3.000 2.000 1.333 0.333 1.333 7 15 12 15 7 5 2 5 8 126 162.8 167.0 0 2024 05 25 33748 33748.5 2602 8 1.667 1.333 1.333 0.667 0.667 1.667 1.333 2.333 6 5 5 3 3 6 5 9 5 104 152.4 156.4 0 2024 05 26 33749 33749.5 2602 9 1.333 2.333 1.000 2.000 2.667 2.667 2.667 1.000 5 9 4 7 12 12 12 4 8 120 155.6 159.7 0
Or like this in the image of the source:
The data result of webread function is just like this :
textweb = webread("https://kp.gfz-potsdam.de/kpdata?startdate=2024-05-21&enddate=2024-05-26&format=kp1#kpdatadownload-143");
textweb =
‘2024 05 21 33744 33744.5 2602 4 1.667 1.000 1.000 2.667 2.667 2.333 1.667 1.667 6 4 4 12 12 9 6 6 7 165 190.8 195.4 0
2024 05 22 33745 33745.5 2602 5 1.667 0.667 0.333 0.333 0.000 0.667 1.333 1.333 6 3 2 2 0 3 5 5 3 152 195.7 200.6 0
2024 05 23 33746 33746.5 2602 6 0.667 1.667 1.667 2.333 2.333 1.667 2.333 4.000 3 6 6 9 9 6 9 27 9 134 176.2 180.7 0
2024 05 24 33747 33747.5 2602 7 2.000 3.000 2.667 3.000 2.000 1.333 0.333 1.333 7 15 12 15 7 5 2 5 8 126 162.8 167.0 0
2024 05 25 33748 33748.5 2602 8 1.667 1.333 1.333 0.667 0.667 1.667 1.333 2.333 6 5 5 3 3 6 5 9 5 104 152.4 156.4 0
2024 05 26 33749 33749.5 2602 9 1.333 2.333 1.000 2.000 2.667 2.667 2.667 1.000 5 9 4 7 12 12 12 4 8 120 155.6 159.7 0
‘
And i want to know how to convert the output of webread function above to become a data like this :
"2024 05 21 33744 33744.5 2602 4 1.667 1.000 1.000 2.667 2.667 2.333 1.667 1.667 6 4 4 12 12 9 6 6 7 165 190.8 195.4 0"
"2024 05 22 33745 33745.5 2602 5 1.667 0.667 0.333 0.333 0.000 0.667 1.333 1.333 6 3 2 2 0 3 5 5 3 152 195.7 200.6 0"
"2024 05 23 33746 33746.5 2602 6 0.667 1.667 1.667 2.333 2.333 1.667 2.333 4.000 3 6 6 9 9 6 9 27 9 134 176.2 180.7 0"
"2024 05 24 33747 33747.5 2602 7 2.000 3.000 2.667 3.000 2.000 1.333 0.333 1.333 7 15 12 15 7 5 2 5 8 126 162.8 167.0 0"
"2024 05 25 33748 33748.5 2602 8 1.667 1.333 1.333 0.667 0.667 1.667 1.333 2.333 6 5 5 3 3 6 5 9 5 104 152.4 156.4 0"
"2024 05 26 33749 33749.5 2602 9 1.333 2.333 1.000 2.000 2.667 2.667 2.667 1.000 5 9 4 7 12 12 12 4 8 120 155.6 159.7 0"
OR just simply save the output of webread function to become a txt file (ASCII) which can be opened in my local PC…
Thank you everyone for your attention and cooperation. I would be very grateful if community can help me to solve this problem /. /. /. read webdata as text MATLAB Answers — New Questions
Turn sequence into a loop
idler_1 = 17;
idler_2 = 17;
idler_3 = 17;
Z_gears(1) = 17;
% Z_gear(1) is defined same holds for the idler’s
% Number of Z_gears is determined by N and gear_ratio_combo goes from (1,1)
% to (1,(columlength)
% idlers are on Z_gear place Z_gear(3),Z_gear(5),Z_gear(7) etc
% but if Z_gear(end) is uneven then do not place idler there
Z_gears(2) = Z_gears(1)*gear_ratio_combo(1,1);
Z_gears(3) = idler_1;
Z_gears(4) = Z_gears(3)*gear_ratio_combo(1,2);
Z_gears(5) = idler_2;
Z_gears(6) = Z_gears(5)*gear_ratio_combo(1,3);
Z_gears(7) = idler_3;
Z_gears(8) = Z_gears(7)*gear_ratio_combo(1,4);idler_1 = 17;
idler_2 = 17;
idler_3 = 17;
Z_gears(1) = 17;
% Z_gear(1) is defined same holds for the idler’s
% Number of Z_gears is determined by N and gear_ratio_combo goes from (1,1)
% to (1,(columlength)
% idlers are on Z_gear place Z_gear(3),Z_gear(5),Z_gear(7) etc
% but if Z_gear(end) is uneven then do not place idler there
Z_gears(2) = Z_gears(1)*gear_ratio_combo(1,1);
Z_gears(3) = idler_1;
Z_gears(4) = Z_gears(3)*gear_ratio_combo(1,2);
Z_gears(5) = idler_2;
Z_gears(6) = Z_gears(5)*gear_ratio_combo(1,3);
Z_gears(7) = idler_3;
Z_gears(8) = Z_gears(7)*gear_ratio_combo(1,4); idler_1 = 17;
idler_2 = 17;
idler_3 = 17;
Z_gears(1) = 17;
% Z_gear(1) is defined same holds for the idler’s
% Number of Z_gears is determined by N and gear_ratio_combo goes from (1,1)
% to (1,(columlength)
% idlers are on Z_gear place Z_gear(3),Z_gear(5),Z_gear(7) etc
% but if Z_gear(end) is uneven then do not place idler there
Z_gears(2) = Z_gears(1)*gear_ratio_combo(1,1);
Z_gears(3) = idler_1;
Z_gears(4) = Z_gears(3)*gear_ratio_combo(1,2);
Z_gears(5) = idler_2;
Z_gears(6) = Z_gears(5)*gear_ratio_combo(1,3);
Z_gears(7) = idler_3;
Z_gears(8) = Z_gears(7)*gear_ratio_combo(1,4); sequences, for loop MATLAB Answers — New Questions
Having problems with the trainnet function
I am trying to fine tune a machine learning model. While using the trainnet function it states "Training stopped: Training loss is NaN" in the command window. The old trainNetwork functions works, which to me makes it weird that trainnet does not. How do I work around this? Possible solutions?I am trying to fine tune a machine learning model. While using the trainnet function it states "Training stopped: Training loss is NaN" in the command window. The old trainNetwork functions works, which to me makes it weird that trainnet does not. How do I work around this? Possible solutions? I am trying to fine tune a machine learning model. While using the trainnet function it states "Training stopped: Training loss is NaN" in the command window. The old trainNetwork functions works, which to me makes it weird that trainnet does not. How do I work around this? Possible solutions? machine learning, image processing MATLAB Answers — New Questions
how aggregate duraration and sum it in timetable
Hi,
it’s a timetable and i want to sum all duration equal:
example:
04/01/2010 2202 1.23
05/01/2010 2202 1.26
……
i want this:
duration value
22:02 2.49 (1.23+1.26)Hi,
it’s a timetable and i want to sum all duration equal:
example:
04/01/2010 2202 1.23
05/01/2010 2202 1.26
……
i want this:
duration value
22:02 2.49 (1.23+1.26) Hi,
it’s a timetable and i want to sum all duration equal:
example:
04/01/2010 2202 1.23
05/01/2010 2202 1.26
……
i want this:
duration value
22:02 2.49 (1.23+1.26) how aggregate duraration and sum it in timetable MATLAB Answers — New Questions
How to resolve the error for creating mask from shape file?
I am using following MATLAB code to create mask using shape file
S = shaperead(shapefile.name);
% Shapefile projections
info = shapeinfo(shapefile.name);
crs = info.CoordinateReferenceSystem;
[S(1).lon,S(1).lat] = projinv(crs,S(1).X,S(1).Y);
%remove small triangles and squares
coord_lengths = arrayfun(@(s) numel(s.X), S);
not_useful_mask = coord_lengths < 10;
S(not_useful_mask) = [];
polygon = polyshape({S(1).lon}, {S(1).lat});
[Z,R] = readgeoraster(‘C:workndvi_2022_23.dat’);
p = R.ProjectedCRS;
[x,y] = worldGrid(R);
[lon,lat] = projinv(p,x,y);
% Create a logical mask
logical_mask = reshape(isinterior(polygon, lon(:), lat(:)), size(lon));
However, it is giving following error;
Ale.shp
Warning: Polyshape has duplicate vertices, intersections, or other inconsistencies that may produce inaccurate or
unexpected results. Input data has been modified to create a well-defined polyshape.
> In polyshape/checkAndSimplify (line 526)
In polyshape (line 175)
In indices_caf (line 45)
Requested 408×5604579 (17.0GB) array exceeds maximum array size preference (15.8GB). This might cause MATLAB to
become unresponsive.
Error in polyshape/isinterior>check_inpolygon (line 65)
x = x(ones(Nv,1),:);
Error in polyshape/isinterior (line 50)
[in, on] = check_inpolygon(X, Y, xv, yv, tol);
Error in indices_caf (line 53)
logical_mask = reshape(isinterior(polygon, lon(:), lat(:)), size(lon));
shape file is attached as zip file while data file is uploaded on following link;
https://drive.google.com/file/d/1aqMYMJDlMOXvamybP-i6eiuo5ehYzdkh/view?usp=sharing
I would appreciate any help.I am using following MATLAB code to create mask using shape file
S = shaperead(shapefile.name);
% Shapefile projections
info = shapeinfo(shapefile.name);
crs = info.CoordinateReferenceSystem;
[S(1).lon,S(1).lat] = projinv(crs,S(1).X,S(1).Y);
%remove small triangles and squares
coord_lengths = arrayfun(@(s) numel(s.X), S);
not_useful_mask = coord_lengths < 10;
S(not_useful_mask) = [];
polygon = polyshape({S(1).lon}, {S(1).lat});
[Z,R] = readgeoraster(‘C:workndvi_2022_23.dat’);
p = R.ProjectedCRS;
[x,y] = worldGrid(R);
[lon,lat] = projinv(p,x,y);
% Create a logical mask
logical_mask = reshape(isinterior(polygon, lon(:), lat(:)), size(lon));
However, it is giving following error;
Ale.shp
Warning: Polyshape has duplicate vertices, intersections, or other inconsistencies that may produce inaccurate or
unexpected results. Input data has been modified to create a well-defined polyshape.
> In polyshape/checkAndSimplify (line 526)
In polyshape (line 175)
In indices_caf (line 45)
Requested 408×5604579 (17.0GB) array exceeds maximum array size preference (15.8GB). This might cause MATLAB to
become unresponsive.
Error in polyshape/isinterior>check_inpolygon (line 65)
x = x(ones(Nv,1),:);
Error in polyshape/isinterior (line 50)
[in, on] = check_inpolygon(X, Y, xv, yv, tol);
Error in indices_caf (line 53)
logical_mask = reshape(isinterior(polygon, lon(:), lat(:)), size(lon));
shape file is attached as zip file while data file is uploaded on following link;
https://drive.google.com/file/d/1aqMYMJDlMOXvamybP-i6eiuo5ehYzdkh/view?usp=sharing
I would appreciate any help. I am using following MATLAB code to create mask using shape file
S = shaperead(shapefile.name);
% Shapefile projections
info = shapeinfo(shapefile.name);
crs = info.CoordinateReferenceSystem;
[S(1).lon,S(1).lat] = projinv(crs,S(1).X,S(1).Y);
%remove small triangles and squares
coord_lengths = arrayfun(@(s) numel(s.X), S);
not_useful_mask = coord_lengths < 10;
S(not_useful_mask) = [];
polygon = polyshape({S(1).lon}, {S(1).lat});
[Z,R] = readgeoraster(‘C:workndvi_2022_23.dat’);
p = R.ProjectedCRS;
[x,y] = worldGrid(R);
[lon,lat] = projinv(p,x,y);
% Create a logical mask
logical_mask = reshape(isinterior(polygon, lon(:), lat(:)), size(lon));
However, it is giving following error;
Ale.shp
Warning: Polyshape has duplicate vertices, intersections, or other inconsistencies that may produce inaccurate or
unexpected results. Input data has been modified to create a well-defined polyshape.
> In polyshape/checkAndSimplify (line 526)
In polyshape (line 175)
In indices_caf (line 45)
Requested 408×5604579 (17.0GB) array exceeds maximum array size preference (15.8GB). This might cause MATLAB to
become unresponsive.
Error in polyshape/isinterior>check_inpolygon (line 65)
x = x(ones(Nv,1),:);
Error in polyshape/isinterior (line 50)
[in, on] = check_inpolygon(X, Y, xv, yv, tol);
Error in indices_caf (line 53)
logical_mask = reshape(isinterior(polygon, lon(:), lat(:)), size(lon));
shape file is attached as zip file while data file is uploaded on following link;
https://drive.google.com/file/d/1aqMYMJDlMOXvamybP-i6eiuo5ehYzdkh/view?usp=sharing
I would appreciate any help. how to resolve the error for creating mask from s MATLAB Answers — New Questions
Matlab Predict function is not efficient
Matlab Predict function is not efficient…Perhaps because it is general suitable for all models. Is there a way to speed it? I am working with incremental regression kernel. Predict takes more time than updatemetricsandfit!Matlab Predict function is not efficient…Perhaps because it is general suitable for all models. Is there a way to speed it? I am working with incremental regression kernel. Predict takes more time than updatemetricsandfit! Matlab Predict function is not efficient…Perhaps because it is general suitable for all models. Is there a way to speed it? I am working with incremental regression kernel. Predict takes more time than updatemetricsandfit! efficient MATLAB Answers — New Questions
How to use the attached excel file below to do a Fourier conversion and display the spectrogram?
How do I use the attached excel file below to do a Fourier conversion and display the spectrogram?How do I use the attached excel file below to do a Fourier conversion and display the spectrogram? How do I use the attached excel file below to do a Fourier conversion and display the spectrogram? fourier conversion and display the spectrogram MATLAB Answers — New Questions