Tag Archives: matlab
How to spline 163 data points into 100 data points?
I have a data set that is a "double" class 163×1 in a numeric matrix, I would like to spline this data into 100 points instead of 163 data points.
Although I have researched and checked on the ‘Help’ section of spline, I have followed it to the best of my abilities and I have searched here for answers, unfortunately I have not found my answer.
Furthermore, when I run through this code that I have created it says that "Index in position 2 is larger than array. This should be less than 1".
z = [lCOMz_FS1_1]’;
x1 = 0:1:99;
y1 = linspace(z(1,1), z(1,163), 100);
COMz = spline(x1,y1);
plot(x1,y1,COMz)
I’d like to thank anyone in advance for such helping me on such a simple code.I have a data set that is a "double" class 163×1 in a numeric matrix, I would like to spline this data into 100 points instead of 163 data points.
Although I have researched and checked on the ‘Help’ section of spline, I have followed it to the best of my abilities and I have searched here for answers, unfortunately I have not found my answer.
Furthermore, when I run through this code that I have created it says that "Index in position 2 is larger than array. This should be less than 1".
z = [lCOMz_FS1_1]’;
x1 = 0:1:99;
y1 = linspace(z(1,1), z(1,163), 100);
COMz = spline(x1,y1);
plot(x1,y1,COMz)
I’d like to thank anyone in advance for such helping me on such a simple code. I have a data set that is a "double" class 163×1 in a numeric matrix, I would like to spline this data into 100 points instead of 163 data points.
Although I have researched and checked on the ‘Help’ section of spline, I have followed it to the best of my abilities and I have searched here for answers, unfortunately I have not found my answer.
Furthermore, when I run through this code that I have created it says that "Index in position 2 is larger than array. This should be less than 1".
z = [lCOMz_FS1_1]’;
x1 = 0:1:99;
y1 = linspace(z(1,1), z(1,163), 100);
COMz = spline(x1,y1);
plot(x1,y1,COMz)
I’d like to thank anyone in advance for such helping me on such a simple code. spline, database, normalisation MATLAB Answers — New Questions
Not able to load the exported MATLAB DL model in TensorFlow
I have use exportNetwork command and got a folder named myModel which contains 4 files init.py, readme.txt, model.py, and weights.h5.
No according to matlab documentation: myModel folder is a package. So we can do
"import myModel
model = myModel.load_model()"
But if i am doing this i am getting error: "ModuleNotFoundError: No module named ‘myModel’"
I am running on colab so what i did is: i uploaded the myModel folder in my drive and then i mounted drive. But not able to install that package. How to load such exported model in python please tell us clearly.
I have tried to make the model using ‘model.py’ code. But then when i am trying to load the weights using kers command:
model = create_model()
weight_path=’/content/drive/MyDrive/VGGish_Arka/weights.h5′
model.load_weights(weight_path)
Error is: "ValueError: Layer count mismatch when loading weights from file. Model expected 9 layers, found 0 saved layers."I have use exportNetwork command and got a folder named myModel which contains 4 files init.py, readme.txt, model.py, and weights.h5.
No according to matlab documentation: myModel folder is a package. So we can do
"import myModel
model = myModel.load_model()"
But if i am doing this i am getting error: "ModuleNotFoundError: No module named ‘myModel’"
I am running on colab so what i did is: i uploaded the myModel folder in my drive and then i mounted drive. But not able to install that package. How to load such exported model in python please tell us clearly.
I have tried to make the model using ‘model.py’ code. But then when i am trying to load the weights using kers command:
model = create_model()
weight_path=’/content/drive/MyDrive/VGGish_Arka/weights.h5′
model.load_weights(weight_path)
Error is: "ValueError: Layer count mismatch when loading weights from file. Model expected 9 layers, found 0 saved layers." I have use exportNetwork command and got a folder named myModel which contains 4 files init.py, readme.txt, model.py, and weights.h5.
No according to matlab documentation: myModel folder is a package. So we can do
"import myModel
model = myModel.load_model()"
But if i am doing this i am getting error: "ModuleNotFoundError: No module named ‘myModel’"
I am running on colab so what i did is: i uploaded the myModel folder in my drive and then i mounted drive. But not able to install that package. How to load such exported model in python please tell us clearly.
I have tried to make the model using ‘model.py’ code. But then when i am trying to load the weights using kers command:
model = create_model()
weight_path=’/content/drive/MyDrive/VGGish_Arka/weights.h5′
model.load_weights(weight_path)
Error is: "ValueError: Layer count mismatch when loading weights from file. Model expected 9 layers, found 0 saved layers." deep learning, exportnetwork, vggish, audio, tensorflow MATLAB Answers — New Questions
Why is the sky blue?
This is a list of stepsStep 1 Step 1a Step 2
A = ones(1,4);B = zeros(1,4);C = [A B]
Restarted StepThis is a list of stepsStep 1 Step 1a Step 2
A = ones(1,4);B = zeros(1,4);C = [A B]
Restarted Step This is a list of stepsStep 1 Step 1a Step 2
A = ones(1,4);B = zeros(1,4);C = [A B]
Restarted Step test, next, and, another MATLAB Answers — New Questions
How to calculate maximum distance between two points (coordinates) on a XY (2D) plane ?
I am plotting two vectors (x and y), i.e. plot x vs. y.
I want to calculate distance between points which are furthest away from each other. I also need their indices to reference a time stamp.
Using pdist2 I get the pink line, but the black line (annotation) seem to be the actual largest distance.I am plotting two vectors (x and y), i.e. plot x vs. y.
I want to calculate distance between points which are furthest away from each other. I also need their indices to reference a time stamp.
Using pdist2 I get the pink line, but the black line (annotation) seem to be the actual largest distance. I am plotting two vectors (x and y), i.e. plot x vs. y.
I want to calculate distance between points which are furthest away from each other. I also need their indices to reference a time stamp.
Using pdist2 I get the pink line, but the black line (annotation) seem to be the actual largest distance. pdist2, pdist, xy, maximum distance MATLAB Answers — New Questions
Hamming Code Encode Error
How to correct the following error?
Unable to resolve the name ‘comm.HammingEncoder’.
Error in Finalcomputerassignment (line 75)
enc = comm.HammingEncoder;
clc;
clear all;
% Load the ‘lenna’ image
lenna = imread(‘lenna.png’);
% Convert the image to grayscale
lenna_gray = rgb2gray(lenna);
% Convert pixel values to bits
lenna_bits = reshape(de2bi(lenna_gray, 8, ‘left-msb’), [], 1);
% Define Eb/No values for low and high SNR
Eb_No_low = 0;
Eb_No_high = 4;
% Modulate using BPSK
modulated_signal = pskmod(lenna_bits, 2);
% Calculate SNR values for low and high SNR, taking into account the noise power in BPSK
% For BPSK, the bit energy is the same as the symbol energy since there is one bit per symbol
SNR_low = Eb_No_low + 10*log10(1);
SNR_high = Eb_No_high + 10*log10(1);
% Transmit and receive at low SNR
received_low = awgn(modulated_signal, SNR_low, ‘measured’);
% Demodulate received signal at low SNR
demodulated_low = pskdemod(received_low, 2);
% Transmit and receive at high SNR
received_high = awgn(modulated_signal, SNR_high, ‘measured’);
% Demodulate received signal at high SNR
demodulated_high = pskdemod(received_high, 2);
% Reshape demodulated bits to original image size
szin = size(lenna_gray,1:2);
decoded_image_low = reshape(demodulated_low, [], 8);
decoded_image_low = uint8(bi2de(decoded_image_low, ‘left-msb’));
decoded_image_low = reshape(decoded_image_low, szin);
decoded_image_high = reshape(demodulated_high, [], 8);
decoded_image_high = uint8(bi2de(decoded_image_high, ‘left-msb’));
decoded_image_high = reshape(decoded_image_high, szin);
% Employ a linear error detection code (only detection and no correction)
% Calculate and display Bit Error Rate (BER)
ber_low = sum(abs(double(lenna_bits) – double(demodulated_low))) / length(lenna_bits);
ber_high = sum(abs(double(lenna_bits) – double(demodulated_high))) / length(lenna_bits);
fprintf(‘BER at low SNR (0 dB): %fn’, ber_low);
fprintf(‘BER at high SNR (4 dB): %fn’, ber_high);
% Plot original, received image at 0 dB SNR, and received image at 4 dB SNR
figure(‘Position’, [100, 100, 1200, 400]);
% Original Image
subplot(1, 3, 1);
imshow(lenna_gray);
title(‘Original Image’);
% Received Image at 0 dB SNR
subplot(1, 3, 2);
imshow(decoded_image_low);
title(‘Received Image (0 dB SNR)’);
% Received Image at 4 dB SNR
subplot(1, 3, 3);
imshow(decoded_image_high);
title(‘Received Image (4 dB SNR)’);
% Task 3: Use an error correction code using syndrome lookup table
% Error correction code
% Let’s use a (7, 4) Hamming code
enc = comm.HammingEncoder;
dec = comm.HammingDecoder;
% Corrected images at 0 dB and 4 dB SNR
corrected_img_low = correct_image(received_signal_low, enc, dec);
corrected_img_high = correct_image(received_signal_high, enc, dec);
% Display corrected images
figure;
subplot(1,2,1);
imshow(corrected_img_low, []);
title(‘Corrected Image (0 dB SNR)’);
subplot(1,2,2);
imshow(corrected_img_high, []);
title(‘Corrected Image (4 dB SNR)’);
% Function to correct image using error correction code
function corrected_img = correct_image(received_signal, enc, dec)
% BPSK demodulation
demodulated_bits = sign(received_signal);
% Perform error detection and correction
detected_bits = step(dec, demodulated_bits);
% Convert bits back to image
corrected_img = reshape((detected_bits + 1) / 2, 8, []).’;
endHow to correct the following error?
Unable to resolve the name ‘comm.HammingEncoder’.
Error in Finalcomputerassignment (line 75)
enc = comm.HammingEncoder;
clc;
clear all;
% Load the ‘lenna’ image
lenna = imread(‘lenna.png’);
% Convert the image to grayscale
lenna_gray = rgb2gray(lenna);
% Convert pixel values to bits
lenna_bits = reshape(de2bi(lenna_gray, 8, ‘left-msb’), [], 1);
% Define Eb/No values for low and high SNR
Eb_No_low = 0;
Eb_No_high = 4;
% Modulate using BPSK
modulated_signal = pskmod(lenna_bits, 2);
% Calculate SNR values for low and high SNR, taking into account the noise power in BPSK
% For BPSK, the bit energy is the same as the symbol energy since there is one bit per symbol
SNR_low = Eb_No_low + 10*log10(1);
SNR_high = Eb_No_high + 10*log10(1);
% Transmit and receive at low SNR
received_low = awgn(modulated_signal, SNR_low, ‘measured’);
% Demodulate received signal at low SNR
demodulated_low = pskdemod(received_low, 2);
% Transmit and receive at high SNR
received_high = awgn(modulated_signal, SNR_high, ‘measured’);
% Demodulate received signal at high SNR
demodulated_high = pskdemod(received_high, 2);
% Reshape demodulated bits to original image size
szin = size(lenna_gray,1:2);
decoded_image_low = reshape(demodulated_low, [], 8);
decoded_image_low = uint8(bi2de(decoded_image_low, ‘left-msb’));
decoded_image_low = reshape(decoded_image_low, szin);
decoded_image_high = reshape(demodulated_high, [], 8);
decoded_image_high = uint8(bi2de(decoded_image_high, ‘left-msb’));
decoded_image_high = reshape(decoded_image_high, szin);
% Employ a linear error detection code (only detection and no correction)
% Calculate and display Bit Error Rate (BER)
ber_low = sum(abs(double(lenna_bits) – double(demodulated_low))) / length(lenna_bits);
ber_high = sum(abs(double(lenna_bits) – double(demodulated_high))) / length(lenna_bits);
fprintf(‘BER at low SNR (0 dB): %fn’, ber_low);
fprintf(‘BER at high SNR (4 dB): %fn’, ber_high);
% Plot original, received image at 0 dB SNR, and received image at 4 dB SNR
figure(‘Position’, [100, 100, 1200, 400]);
% Original Image
subplot(1, 3, 1);
imshow(lenna_gray);
title(‘Original Image’);
% Received Image at 0 dB SNR
subplot(1, 3, 2);
imshow(decoded_image_low);
title(‘Received Image (0 dB SNR)’);
% Received Image at 4 dB SNR
subplot(1, 3, 3);
imshow(decoded_image_high);
title(‘Received Image (4 dB SNR)’);
% Task 3: Use an error correction code using syndrome lookup table
% Error correction code
% Let’s use a (7, 4) Hamming code
enc = comm.HammingEncoder;
dec = comm.HammingDecoder;
% Corrected images at 0 dB and 4 dB SNR
corrected_img_low = correct_image(received_signal_low, enc, dec);
corrected_img_high = correct_image(received_signal_high, enc, dec);
% Display corrected images
figure;
subplot(1,2,1);
imshow(corrected_img_low, []);
title(‘Corrected Image (0 dB SNR)’);
subplot(1,2,2);
imshow(corrected_img_high, []);
title(‘Corrected Image (4 dB SNR)’);
% Function to correct image using error correction code
function corrected_img = correct_image(received_signal, enc, dec)
% BPSK demodulation
demodulated_bits = sign(received_signal);
% Perform error detection and correction
detected_bits = step(dec, demodulated_bits);
% Convert bits back to image
corrected_img = reshape((detected_bits + 1) / 2, 8, []).’;
end How to correct the following error?
Unable to resolve the name ‘comm.HammingEncoder’.
Error in Finalcomputerassignment (line 75)
enc = comm.HammingEncoder;
clc;
clear all;
% Load the ‘lenna’ image
lenna = imread(‘lenna.png’);
% Convert the image to grayscale
lenna_gray = rgb2gray(lenna);
% Convert pixel values to bits
lenna_bits = reshape(de2bi(lenna_gray, 8, ‘left-msb’), [], 1);
% Define Eb/No values for low and high SNR
Eb_No_low = 0;
Eb_No_high = 4;
% Modulate using BPSK
modulated_signal = pskmod(lenna_bits, 2);
% Calculate SNR values for low and high SNR, taking into account the noise power in BPSK
% For BPSK, the bit energy is the same as the symbol energy since there is one bit per symbol
SNR_low = Eb_No_low + 10*log10(1);
SNR_high = Eb_No_high + 10*log10(1);
% Transmit and receive at low SNR
received_low = awgn(modulated_signal, SNR_low, ‘measured’);
% Demodulate received signal at low SNR
demodulated_low = pskdemod(received_low, 2);
% Transmit and receive at high SNR
received_high = awgn(modulated_signal, SNR_high, ‘measured’);
% Demodulate received signal at high SNR
demodulated_high = pskdemod(received_high, 2);
% Reshape demodulated bits to original image size
szin = size(lenna_gray,1:2);
decoded_image_low = reshape(demodulated_low, [], 8);
decoded_image_low = uint8(bi2de(decoded_image_low, ‘left-msb’));
decoded_image_low = reshape(decoded_image_low, szin);
decoded_image_high = reshape(demodulated_high, [], 8);
decoded_image_high = uint8(bi2de(decoded_image_high, ‘left-msb’));
decoded_image_high = reshape(decoded_image_high, szin);
% Employ a linear error detection code (only detection and no correction)
% Calculate and display Bit Error Rate (BER)
ber_low = sum(abs(double(lenna_bits) – double(demodulated_low))) / length(lenna_bits);
ber_high = sum(abs(double(lenna_bits) – double(demodulated_high))) / length(lenna_bits);
fprintf(‘BER at low SNR (0 dB): %fn’, ber_low);
fprintf(‘BER at high SNR (4 dB): %fn’, ber_high);
% Plot original, received image at 0 dB SNR, and received image at 4 dB SNR
figure(‘Position’, [100, 100, 1200, 400]);
% Original Image
subplot(1, 3, 1);
imshow(lenna_gray);
title(‘Original Image’);
% Received Image at 0 dB SNR
subplot(1, 3, 2);
imshow(decoded_image_low);
title(‘Received Image (0 dB SNR)’);
% Received Image at 4 dB SNR
subplot(1, 3, 3);
imshow(decoded_image_high);
title(‘Received Image (4 dB SNR)’);
% Task 3: Use an error correction code using syndrome lookup table
% Error correction code
% Let’s use a (7, 4) Hamming code
enc = comm.HammingEncoder;
dec = comm.HammingDecoder;
% Corrected images at 0 dB and 4 dB SNR
corrected_img_low = correct_image(received_signal_low, enc, dec);
corrected_img_high = correct_image(received_signal_high, enc, dec);
% Display corrected images
figure;
subplot(1,2,1);
imshow(corrected_img_low, []);
title(‘Corrected Image (0 dB SNR)’);
subplot(1,2,2);
imshow(corrected_img_high, []);
title(‘Corrected Image (4 dB SNR)’);
% Function to correct image using error correction code
function corrected_img = correct_image(received_signal, enc, dec)
% BPSK demodulation
demodulated_bits = sign(received_signal);
% Perform error detection and correction
detected_bits = step(dec, demodulated_bits);
% Convert bits back to image
corrected_img = reshape((detected_bits + 1) / 2, 8, []).’;
end hamming code error MATLAB Answers — New Questions
Aerodynamic forces and moments
In the "Aerodynamic Forces and Moments" block, are the x/y/z forces assumed to act at the CG (such that the resulting moment from the forces acting at another point would need to be included in the moment coefficient about each axis)?In the "Aerodynamic Forces and Moments" block, are the x/y/z forces assumed to act at the CG (such that the resulting moment from the forces acting at another point would need to be included in the moment coefficient about each axis)? In the "Aerodynamic Forces and Moments" block, are the x/y/z forces assumed to act at the CG (such that the resulting moment from the forces acting at another point would need to be included in the moment coefficient about each axis)? aerodynamic forces MATLAB Answers — New Questions
Find the result of factorial N entered from keyboard and displaying the result in 3 decimals with an expression “the result is found as …….
import math
N = int(input("Enter a number: "))
fact = math.factorial(N)
result = round(fact, 3)
print(f"the result is found as {result}")import math
N = int(input("Enter a number: "))
fact = math.factorial(N)
result = round(fact, 3)
print(f"the result is found as {result}") import math
N = int(input("Enter a number: "))
fact = math.factorial(N)
result = round(fact, 3)
print(f"the result is found as {result}") find the result of factorial n entered from keyboa MATLAB Answers — New Questions
char array to numeric array
Hi,
I generated a datafile which has numeric values, but in the char array. Each row has several values in one column that are supposed to be in different columns/arrays. I tried split/str2num/str2double/double and some others. I am unable to convert this char array into numeric array with multiple rows and columns. I was wondering if there was a better way of doing this?Hi,
I generated a datafile which has numeric values, but in the char array. Each row has several values in one column that are supposed to be in different columns/arrays. I tried split/str2num/str2double/double and some others. I am unable to convert this char array into numeric array with multiple rows and columns. I was wondering if there was a better way of doing this? Hi,
I generated a datafile which has numeric values, but in the char array. Each row has several values in one column that are supposed to be in different columns/arrays. I tried split/str2num/str2double/double and some others. I am unable to convert this char array into numeric array with multiple rows and columns. I was wondering if there was a better way of doing this? #chararrays #chartonum #double MATLAB Answers — New Questions
artificial neural network bias
Hi all,
I have developed an artificial neural network with a single hidden layer. The purpose of this is to predict as a probability when a cliff will fail given wave, sea level and precipitation data. To do this I have used the ‘fitnet’ function. However, I am still very new to neural networks and dont fully understand the parameters behind them. Currently, the network is reproducing the test data ok ish however it is struggling to produce the validation data. This is because I have input the cliff failures as a binary column which has cliff failures as 1 and no failures as 0. There are approximately 30 failures which occur across 262 days. The issue is that the network is heavily biased towards reproducing non-failures and therefore when it attempts to predict the validation data does not predict any failures. This means the network ouputs more zeros than required since the training data is mostly zeros since most days experience no cliff failure. I am aware that there is potential to use a grid search to optimise the hyper parameters but I am unsure how to do this. How can I adjust the bias to reproduce more representative results.
Any help would be greatly appreciated.Hi all,
I have developed an artificial neural network with a single hidden layer. The purpose of this is to predict as a probability when a cliff will fail given wave, sea level and precipitation data. To do this I have used the ‘fitnet’ function. However, I am still very new to neural networks and dont fully understand the parameters behind them. Currently, the network is reproducing the test data ok ish however it is struggling to produce the validation data. This is because I have input the cliff failures as a binary column which has cliff failures as 1 and no failures as 0. There are approximately 30 failures which occur across 262 days. The issue is that the network is heavily biased towards reproducing non-failures and therefore when it attempts to predict the validation data does not predict any failures. This means the network ouputs more zeros than required since the training data is mostly zeros since most days experience no cliff failure. I am aware that there is potential to use a grid search to optimise the hyper parameters but I am unsure how to do this. How can I adjust the bias to reproduce more representative results.
Any help would be greatly appreciated. Hi all,
I have developed an artificial neural network with a single hidden layer. The purpose of this is to predict as a probability when a cliff will fail given wave, sea level and precipitation data. To do this I have used the ‘fitnet’ function. However, I am still very new to neural networks and dont fully understand the parameters behind them. Currently, the network is reproducing the test data ok ish however it is struggling to produce the validation data. This is because I have input the cliff failures as a binary column which has cliff failures as 1 and no failures as 0. There are approximately 30 failures which occur across 262 days. The issue is that the network is heavily biased towards reproducing non-failures and therefore when it attempts to predict the validation data does not predict any failures. This means the network ouputs more zeros than required since the training data is mostly zeros since most days experience no cliff failure. I am aware that there is potential to use a grid search to optimise the hyper parameters but I am unsure how to do this. How can I adjust the bias to reproduce more representative results.
Any help would be greatly appreciated. neural network, neural networks, ai, machine learning, binary, fitnet, bias, deep learning MATLAB Answers — New Questions
How do structures work?
How do structures work? I’ve been trying a smoewhat big struct file but the workspace cannot seem to be able to find the values of the structure (the values of the fields are missing). Here is the code. Please help me I do not know what to do.
Default_GP = struct ( …%
…% — Connection Properties —
…%
‘Platform’, "B200", …
‘SerialNum’, "321E19C", …
…%
…% — Configuration Propreties —
…%
…% Frequency
…%
‘CenterFrequency’, 101e6, …
‘FrequencyCorrection’, 0, … //LO offset
‘FrequencyStepsString’ ,{{‘1 Hz’,’10 Hz’,’100 Hz’,’1 kHz’,’10 kHz’,’100 kHz’,’1 MHz’,’10 MHz’,’100 MHz’}}, …
‘AllFrequencySteps’,[1,10,100,1e3,10e3,100e3,1e6,10e6,100e6],…
‘FrequencyStep’,100e3,…
…%
…% Reciever Gain
…%
‘RecieverGain’, 0,… % 76 dB – max reciver gain
…
…
‘AllPPSSources’, {{"Internal", "External", "GPSDO"}},…
‘PPSSource’, "Internal",…
‘AllClockSources’, {{"Internal", "External", "GPSDO"}},…
‘ClockSource’, "Internal",…
…%
…% Output
…%
‘AllSampleRates’, {},… % range of sample rates 5MHz – 61.44MHz
‘SampleRateSteps’, {{‘0.1 MHz’, ‘1 MHz’,’10 MHz’}},…
‘AllSampleRateSteps’, [0.1e6, 1e6, 10e6],…
‘SampleRate’, 32e6,… % Master Clock Rate
…
‘TransportDataTypeStrings’, {{"int16", "int8"}},…
‘TransportDataType’, "int16",…
‘OutputDataTypeString’, {{"int16", "int18", "single", "double"}},…
‘OutputDataType’, "double",…
…
‘AllSamplesPerFrameString’,{{‘4096′,’8192′,’16384′,’32768′,’65536′,’131072′,’262144’}},…
‘AllSamplesPerFrame’,[4096,8192,16384,32768,65536,131072,262144],…
‘SamplesPerFrame’,131072,…
…
‘EnableBurstMode’,false,… % Ensure a set of frames without overrun of USRP B200 output
‘NumFramesInBurst’,10,… % Number of frames in contiguous burstof USRP B200 output
…%
…% Baseband Decimation
…%
‘AllDecimationFactorsRanges’, {{‘[1, 128]’, ‘[128, 256]’, ‘[256-512]’}},…
‘DecimationMultiplesOf’, [1, 2, 4],…
‘DecimationFactor’, 1); % to be addedHow do structures work? I’ve been trying a smoewhat big struct file but the workspace cannot seem to be able to find the values of the structure (the values of the fields are missing). Here is the code. Please help me I do not know what to do.
Default_GP = struct ( …%
…% — Connection Properties —
…%
‘Platform’, "B200", …
‘SerialNum’, "321E19C", …
…%
…% — Configuration Propreties —
…%
…% Frequency
…%
‘CenterFrequency’, 101e6, …
‘FrequencyCorrection’, 0, … //LO offset
‘FrequencyStepsString’ ,{{‘1 Hz’,’10 Hz’,’100 Hz’,’1 kHz’,’10 kHz’,’100 kHz’,’1 MHz’,’10 MHz’,’100 MHz’}}, …
‘AllFrequencySteps’,[1,10,100,1e3,10e3,100e3,1e6,10e6,100e6],…
‘FrequencyStep’,100e3,…
…%
…% Reciever Gain
…%
‘RecieverGain’, 0,… % 76 dB – max reciver gain
…
…
‘AllPPSSources’, {{"Internal", "External", "GPSDO"}},…
‘PPSSource’, "Internal",…
‘AllClockSources’, {{"Internal", "External", "GPSDO"}},…
‘ClockSource’, "Internal",…
…%
…% Output
…%
‘AllSampleRates’, {},… % range of sample rates 5MHz – 61.44MHz
‘SampleRateSteps’, {{‘0.1 MHz’, ‘1 MHz’,’10 MHz’}},…
‘AllSampleRateSteps’, [0.1e6, 1e6, 10e6],…
‘SampleRate’, 32e6,… % Master Clock Rate
…
‘TransportDataTypeStrings’, {{"int16", "int8"}},…
‘TransportDataType’, "int16",…
‘OutputDataTypeString’, {{"int16", "int18", "single", "double"}},…
‘OutputDataType’, "double",…
…
‘AllSamplesPerFrameString’,{{‘4096′,’8192′,’16384′,’32768′,’65536′,’131072′,’262144’}},…
‘AllSamplesPerFrame’,[4096,8192,16384,32768,65536,131072,262144],…
‘SamplesPerFrame’,131072,…
…
‘EnableBurstMode’,false,… % Ensure a set of frames without overrun of USRP B200 output
‘NumFramesInBurst’,10,… % Number of frames in contiguous burstof USRP B200 output
…%
…% Baseband Decimation
…%
‘AllDecimationFactorsRanges’, {{‘[1, 128]’, ‘[128, 256]’, ‘[256-512]’}},…
‘DecimationMultiplesOf’, [1, 2, 4],…
‘DecimationFactor’, 1); % to be added How do structures work? I’ve been trying a smoewhat big struct file but the workspace cannot seem to be able to find the values of the structure (the values of the fields are missing). Here is the code. Please help me I do not know what to do.
Default_GP = struct ( …%
…% — Connection Properties —
…%
‘Platform’, "B200", …
‘SerialNum’, "321E19C", …
…%
…% — Configuration Propreties —
…%
…% Frequency
…%
‘CenterFrequency’, 101e6, …
‘FrequencyCorrection’, 0, … //LO offset
‘FrequencyStepsString’ ,{{‘1 Hz’,’10 Hz’,’100 Hz’,’1 kHz’,’10 kHz’,’100 kHz’,’1 MHz’,’10 MHz’,’100 MHz’}}, …
‘AllFrequencySteps’,[1,10,100,1e3,10e3,100e3,1e6,10e6,100e6],…
‘FrequencyStep’,100e3,…
…%
…% Reciever Gain
…%
‘RecieverGain’, 0,… % 76 dB – max reciver gain
…
…
‘AllPPSSources’, {{"Internal", "External", "GPSDO"}},…
‘PPSSource’, "Internal",…
‘AllClockSources’, {{"Internal", "External", "GPSDO"}},…
‘ClockSource’, "Internal",…
…%
…% Output
…%
‘AllSampleRates’, {},… % range of sample rates 5MHz – 61.44MHz
‘SampleRateSteps’, {{‘0.1 MHz’, ‘1 MHz’,’10 MHz’}},…
‘AllSampleRateSteps’, [0.1e6, 1e6, 10e6],…
‘SampleRate’, 32e6,… % Master Clock Rate
…
‘TransportDataTypeStrings’, {{"int16", "int8"}},…
‘TransportDataType’, "int16",…
‘OutputDataTypeString’, {{"int16", "int18", "single", "double"}},…
‘OutputDataType’, "double",…
…
‘AllSamplesPerFrameString’,{{‘4096′,’8192′,’16384′,’32768′,’65536′,’131072′,’262144’}},…
‘AllSamplesPerFrame’,[4096,8192,16384,32768,65536,131072,262144],…
‘SamplesPerFrame’,131072,…
…
‘EnableBurstMode’,false,… % Ensure a set of frames without overrun of USRP B200 output
‘NumFramesInBurst’,10,… % Number of frames in contiguous burstof USRP B200 output
…%
…% Baseband Decimation
…%
‘AllDecimationFactorsRanges’, {{‘[1, 128]’, ‘[128, 256]’, ‘[256-512]’}},…
‘DecimationMultiplesOf’, [1, 2, 4],…
‘DecimationFactor’, 1); % to be added structures, workspace, command MATLAB Answers — New Questions
plotting a 3d graph for a 3d table
I have a table and I want to plot a 3d graph for that.I have a table and I want to plot a 3d graph for that. I have a table and I want to plot a 3d graph for that. 3d plot MATLAB Answers — New Questions
Unable to open Unreal 5.1 Engine through Simulink after installation
I am in the process of migrating from Unreal Engine 4.27 to 5.1.1 for the purposes of simulation. I have downloaded R2024a and the new engine and followed this tutorial to put the MathWorks plugins in the directory (https://www.mathworks.com/help/vdynblks/ug/install-support-package-and-configure-environment.html) , however when I try and open an unreal project I get this error saying that it is unable to located some file from the Geospatial dll. The unreal engine then crashes and I am not sure what I did wrong. I still have 4.27 installed on my machine as well as old versions of MATLAB such as 23a and 23b.I am in the process of migrating from Unreal Engine 4.27 to 5.1.1 for the purposes of simulation. I have downloaded R2024a and the new engine and followed this tutorial to put the MathWorks plugins in the directory (https://www.mathworks.com/help/vdynblks/ug/install-support-package-and-configure-environment.html) , however when I try and open an unreal project I get this error saying that it is unable to located some file from the Geospatial dll. The unreal engine then crashes and I am not sure what I did wrong. I still have 4.27 installed on my machine as well as old versions of MATLAB such as 23a and 23b. I am in the process of migrating from Unreal Engine 4.27 to 5.1.1 for the purposes of simulation. I have downloaded R2024a and the new engine and followed this tutorial to put the MathWorks plugins in the directory (https://www.mathworks.com/help/vdynblks/ug/install-support-package-and-configure-environment.html) , however when I try and open an unreal project I get this error saying that it is unable to located some file from the Geospatial dll. The unreal engine then crashes and I am not sure what I did wrong. I still have 4.27 installed on my machine as well as old versions of MATLAB such as 23a and 23b. unreal engine, simulink MATLAB Answers — New Questions
3-phase programmable voltage source output
Hello,
I am using a 3 phase programmable voltage source with Amplitude(Vrm Ph-Ph) set to 600 V Phase set to 0 and Freq(Hz) set to 60. I am using a 3ph V-I mesaurement to read the voltages(phase-to-ground). The peak voltage reading from V-I measurement block is coming something around 489.9V. Can someone please explain why is it showing 489V?Hello,
I am using a 3 phase programmable voltage source with Amplitude(Vrm Ph-Ph) set to 600 V Phase set to 0 and Freq(Hz) set to 60. I am using a 3ph V-I mesaurement to read the voltages(phase-to-ground). The peak voltage reading from V-I measurement block is coming something around 489.9V. Can someone please explain why is it showing 489V? Hello,
I am using a 3 phase programmable voltage source with Amplitude(Vrm Ph-Ph) set to 600 V Phase set to 0 and Freq(Hz) set to 60. I am using a 3ph V-I mesaurement to read the voltages(phase-to-ground). The peak voltage reading from V-I measurement block is coming something around 489.9V. Can someone please explain why is it showing 489V? simscape MATLAB Answers — New Questions
Unable to perform assignment because the size of the left side is 1-by-2 and the size of the right side is 1-by-3. Error in pso_process_svc (line 31)
I am running a simulation on the location and sizing of svc on ieee 57 using pso algorithm.
It keeps displaying this error’
‘Unable to perform assignment because the size of the left side is 1-by-2 and the size of the right side is 1-by-3.
Error in pso_process_svc (line 31)
data_initial_pso_pop(indexloop,:) = DGsize_first_para;
Error in TOP_PSO (line 74)
[finalres,FINAL_SVC_LOCATION_SIZE,prop_best_datapso]=pso_process_svc(nbus,int_pop_size,…
please I need help in debugging this problemI am running a simulation on the location and sizing of svc on ieee 57 using pso algorithm.
It keeps displaying this error’
‘Unable to perform assignment because the size of the left side is 1-by-2 and the size of the right side is 1-by-3.
Error in pso_process_svc (line 31)
data_initial_pso_pop(indexloop,:) = DGsize_first_para;
Error in TOP_PSO (line 74)
[finalres,FINAL_SVC_LOCATION_SIZE,prop_best_datapso]=pso_process_svc(nbus,int_pop_size,…
please I need help in debugging this problem I am running a simulation on the location and sizing of svc on ieee 57 using pso algorithm.
It keeps displaying this error’
‘Unable to perform assignment because the size of the left side is 1-by-2 and the size of the right side is 1-by-3.
Error in pso_process_svc (line 31)
data_initial_pso_pop(indexloop,:) = DGsize_first_para;
Error in TOP_PSO (line 74)
[finalres,FINAL_SVC_LOCATION_SIZE,prop_best_datapso]=pso_process_svc(nbus,int_pop_size,…
please I need help in debugging this problem pso MATLAB Answers — New Questions
I want to use a backgroudpool to open a class
Hello,
I want to write a Matlab code that controls a device via an API. I want to implemement a Function that runs in the background and records data out of the device.
That is how i start the function in my maincode:
f1 = parfeval(Pool, @Measurement, 0, actualSystemValuesInstance);
The actualSystemValuesInstance variable holds the class needed to request data from the device. This is my function to handle the Task.
function [] = Measurement(actualSystemValuesInstance)
fileID = fopen(‘data.csv’, ‘a+’);
fmtstr = ‘%12.12f;%12.12f;%12.12frn’;
t = timer();
t.Period = 1;
t.ExecutionMode = ‘fixedRate’;
t.BusyMode = ‘queue’;
t.TimerFcn = @recordData;
function recordData(~, ~)
outputcurrent = actualSystemValuesInstance.GetOutputCurrent();
outputvoltage = actualSystemValuesInstance.GetOutputVoltage();
time = now;
fprintf(fileID, fmtstr, outputvoltage, outputcurrent, time);
end
end
My Problem is, that my Function isnt starting because the class is unknown. Is there a diffrent was to hand over the class to my function?
I also tried to opend and define the API with the classes in the background, there i also get an error. Furthermore I tested the same situation with parpool, there I have the same problem that the class arrives empty in my function.
Is it even possible to use parallel Functions in my application?
PS:
I wanted to use the function in the backround, that my measurements cant be blocked by other runtimes in my Maincode and i wanted to try to do it without timer controled interrrupts.Hello,
I want to write a Matlab code that controls a device via an API. I want to implemement a Function that runs in the background and records data out of the device.
That is how i start the function in my maincode:
f1 = parfeval(Pool, @Measurement, 0, actualSystemValuesInstance);
The actualSystemValuesInstance variable holds the class needed to request data from the device. This is my function to handle the Task.
function [] = Measurement(actualSystemValuesInstance)
fileID = fopen(‘data.csv’, ‘a+’);
fmtstr = ‘%12.12f;%12.12f;%12.12frn’;
t = timer();
t.Period = 1;
t.ExecutionMode = ‘fixedRate’;
t.BusyMode = ‘queue’;
t.TimerFcn = @recordData;
function recordData(~, ~)
outputcurrent = actualSystemValuesInstance.GetOutputCurrent();
outputvoltage = actualSystemValuesInstance.GetOutputVoltage();
time = now;
fprintf(fileID, fmtstr, outputvoltage, outputcurrent, time);
end
end
My Problem is, that my Function isnt starting because the class is unknown. Is there a diffrent was to hand over the class to my function?
I also tried to opend and define the API with the classes in the background, there i also get an error. Furthermore I tested the same situation with parpool, there I have the same problem that the class arrives empty in my function.
Is it even possible to use parallel Functions in my application?
PS:
I wanted to use the function in the backround, that my measurements cant be blocked by other runtimes in my Maincode and i wanted to try to do it without timer controled interrrupts. Hello,
I want to write a Matlab code that controls a device via an API. I want to implemement a Function that runs in the background and records data out of the device.
That is how i start the function in my maincode:
f1 = parfeval(Pool, @Measurement, 0, actualSystemValuesInstance);
The actualSystemValuesInstance variable holds the class needed to request data from the device. This is my function to handle the Task.
function [] = Measurement(actualSystemValuesInstance)
fileID = fopen(‘data.csv’, ‘a+’);
fmtstr = ‘%12.12f;%12.12f;%12.12frn’;
t = timer();
t.Period = 1;
t.ExecutionMode = ‘fixedRate’;
t.BusyMode = ‘queue’;
t.TimerFcn = @recordData;
function recordData(~, ~)
outputcurrent = actualSystemValuesInstance.GetOutputCurrent();
outputvoltage = actualSystemValuesInstance.GetOutputVoltage();
time = now;
fprintf(fileID, fmtstr, outputvoltage, outputcurrent, time);
end
end
My Problem is, that my Function isnt starting because the class is unknown. Is there a diffrent was to hand over the class to my function?
I also tried to opend and define the API with the classes in the background, there i also get an error. Furthermore I tested the same situation with parpool, there I have the same problem that the class arrives empty in my function.
Is it even possible to use parallel Functions in my application?
PS:
I wanted to use the function in the backround, that my measurements cant be blocked by other runtimes in my Maincode and i wanted to try to do it without timer controled interrrupts. backgroundpool, parallel computing, parfeval MATLAB Answers — New Questions
animation with the command show(robot) is very, very slow
Within a robotics class, in the control loop, I have the following code to render the robot movement:
show(robot,q_Gen,’PreservePlot’,true,’Frames’,’off’);
hold on
plot3(xd(1,1:i),xd(2,1:i),xd(3,1:i),’r’)
axis([-.4 .4 -.4 .4 -.1 1])
view(45,35)
drawnow
hold off
The robot has been defined outside of the loop by the command
robot = loadrobot(‘kinovaGen3′,’DataFormat’,’row’,’Gravity’,[0 0 -9.81]);
The animation is very, very slow in any o.s. and PC where it has been tried (Linux, Windows, MAC).
Is it a drawback that can not be avoided?Within a robotics class, in the control loop, I have the following code to render the robot movement:
show(robot,q_Gen,’PreservePlot’,true,’Frames’,’off’);
hold on
plot3(xd(1,1:i),xd(2,1:i),xd(3,1:i),’r’)
axis([-.4 .4 -.4 .4 -.1 1])
view(45,35)
drawnow
hold off
The robot has been defined outside of the loop by the command
robot = loadrobot(‘kinovaGen3′,’DataFormat’,’row’,’Gravity’,[0 0 -9.81]);
The animation is very, very slow in any o.s. and PC where it has been tried (Linux, Windows, MAC).
Is it a drawback that can not be avoided? Within a robotics class, in the control loop, I have the following code to render the robot movement:
show(robot,q_Gen,’PreservePlot’,true,’Frames’,’off’);
hold on
plot3(xd(1,1:i),xd(2,1:i),xd(3,1:i),’r’)
axis([-.4 .4 -.4 .4 -.1 1])
view(45,35)
drawnow
hold off
The robot has been defined outside of the loop by the command
robot = loadrobot(‘kinovaGen3′,’DataFormat’,’row’,’Gravity’,[0 0 -9.81]);
The animation is very, very slow in any o.s. and PC where it has been tried (Linux, Windows, MAC).
Is it a drawback that can not be avoided? drawnow, animation, show robot MATLAB Answers — New Questions
I tried this code but it gives me an error
There are 8 antennas placed in a circle and there are two sources in the far field from which rays are coming and are incident on these antennas. The mathematical formula for array factor "AF" is given in the attachment. This derivation of this formula is also attached. Now if the angles of those two sources are 30 and 70 respectively which I assign to a vector u. Then I want to put these angles one by one while spanning all the 8 antennas. I mean when I put angle 30 in the formula, then the AF should be calculated over all the 8 antennas. Likewise then put the 2nd angle 70 in the formula and calculate the AF over all the 8 antennas. So when I check the AF, it should be an 8 x 2 matrix where 8 are antennas and 2 are angles. I have tried for its code as below but it gives me an error:
clear;clc
f=1e9;% frequency
c=3e8;% speed of light
l=c/f;% lambda
k=(2*pi)/l;% wavenumber
N=8;% Number of antennas
n=0:N-1;
phi_n=2*pi*n/N;
u=[30 70];% The two Angles
M=length(u);% Number of angles
d_circular=l/2;% spacing b/w elements
circumference = N*d_circular;
a = circumference/2*pi; % Radius
for sourceNo=1:M
for m=0:N-1
% AF = sgma from n=0 to N-1 (exp(-1j*k*a*cos(phi-phin))
AF(m)=sum(exp(-1i*k*a*(cos(u(sourceNo)-phi_n))));
end
end
AFThere are 8 antennas placed in a circle and there are two sources in the far field from which rays are coming and are incident on these antennas. The mathematical formula for array factor "AF" is given in the attachment. This derivation of this formula is also attached. Now if the angles of those two sources are 30 and 70 respectively which I assign to a vector u. Then I want to put these angles one by one while spanning all the 8 antennas. I mean when I put angle 30 in the formula, then the AF should be calculated over all the 8 antennas. Likewise then put the 2nd angle 70 in the formula and calculate the AF over all the 8 antennas. So when I check the AF, it should be an 8 x 2 matrix where 8 are antennas and 2 are angles. I have tried for its code as below but it gives me an error:
clear;clc
f=1e9;% frequency
c=3e8;% speed of light
l=c/f;% lambda
k=(2*pi)/l;% wavenumber
N=8;% Number of antennas
n=0:N-1;
phi_n=2*pi*n/N;
u=[30 70];% The two Angles
M=length(u);% Number of angles
d_circular=l/2;% spacing b/w elements
circumference = N*d_circular;
a = circumference/2*pi; % Radius
for sourceNo=1:M
for m=0:N-1
% AF = sgma from n=0 to N-1 (exp(-1j*k*a*cos(phi-phin))
AF(m)=sum(exp(-1i*k*a*(cos(u(sourceNo)-phi_n))));
end
end
AF There are 8 antennas placed in a circle and there are two sources in the far field from which rays are coming and are incident on these antennas. The mathematical formula for array factor "AF" is given in the attachment. This derivation of this formula is also attached. Now if the angles of those two sources are 30 and 70 respectively which I assign to a vector u. Then I want to put these angles one by one while spanning all the 8 antennas. I mean when I put angle 30 in the formula, then the AF should be calculated over all the 8 antennas. Likewise then put the 2nd angle 70 in the formula and calculate the AF over all the 8 antennas. So when I check the AF, it should be an 8 x 2 matrix where 8 are antennas and 2 are angles. I have tried for its code as below but it gives me an error:
clear;clc
f=1e9;% frequency
c=3e8;% speed of light
l=c/f;% lambda
k=(2*pi)/l;% wavenumber
N=8;% Number of antennas
n=0:N-1;
phi_n=2*pi*n/N;
u=[30 70];% The two Angles
M=length(u);% Number of angles
d_circular=l/2;% spacing b/w elements
circumference = N*d_circular;
a = circumference/2*pi; % Radius
for sourceNo=1:M
for m=0:N-1
% AF = sgma from n=0 to N-1 (exp(-1j*k*a*cos(phi-phin))
AF(m)=sum(exp(-1i*k*a*(cos(u(sourceNo)-phi_n))));
end
end
AF code gives an error, how to modify MATLAB Answers — New Questions
Change de default position of plot
Dear;
This a silly question
Sometimes when I debug a program I need to plot some of the variables in different figures
The figure apear just in the middle of the script editor, so to continued debugging I have to move the plot
Is there any way to chage the default position where the plot appears?
Many thanks,Dear;
This a silly question
Sometimes when I debug a program I need to plot some of the variables in different figures
The figure apear just in the middle of the script editor, so to continued debugging I have to move the plot
Is there any way to chage the default position where the plot appears?
Many thanks, Dear;
This a silly question
Sometimes when I debug a program I need to plot some of the variables in different figures
The figure apear just in the middle of the script editor, so to continued debugging I have to move the plot
Is there any way to chage the default position where the plot appears?
Many thanks, default position of plot figure MATLAB Answers — New Questions
My one-sample t-test isn’t working as I need it to.
Hello everyone. I need to calculate the p-value for each sample with different dimensions and compare them with the reference value, which is the largest sample at 100 mm. I need to perform a one-sample t-test with a significance level of 0.05. Here is my code. I don’t know why it always outputs NaN for the 80 mm value. I would like to fix this.
My Code:
% Clear the workspace, command window, and close any open figures
clc;
clear all;
close all;
% Input data
data = [67.142880, 69.218820, 67.379050, 69.943850, 67.407470]; % Data values
rozmery = [100, 80, 60, 40, 20]; % Dimensions
reference_value = data(1); % Reference value
% Significance level
alpha = 0.05;
% Initialize an array to store p-values
p_values = zeros(1, length(data) – 1);
% Perform t-tests and calculate p-values for each subsequent data point
for i = 2:length(data)
% Perform a one-sample t-test
[~, p_values(i-1)] = ttest2(data(1:i-1), data(i), ‘Alpha’, alpha);
end
% Plot the graph
figure;
plot(rozmery(2:end), p_values, ‘-o’, ‘LineWidth’, 2); % Plot dimensions against p-values
xlabel(‘Dimensions (mm)’); % X-axis label
ylabel(‘P-values’); % Y-axis label
title(‘P-values vs Dimensions’); % Title of the plot
grid on; % Turn on the grid
% Add labels to the plot
for i = 2:length(rozmery)
text(rozmery(i), p_values(i-1), sprintf(‘(%d, %f)’, rozmery(i), p_values(i-1)),…
‘VerticalAlignment’, ‘bottom’, ‘HorizontalAlignment’, ‘left’);
% Add text annotations for each point on the plot
end
% Display the corresponding dimension values and p-values
for i = 2:length(rozmery)
fprintf(‘P-value for dimension %d mm: %fn’, rozmery(i), p_values(i-1));
end
% Find the point where the p-value falls below the significance level
index_rustu = find(p_values < alpha, 1);
% Display the point where the p-value falls below the significance level
if ~isempty(index_rustu)
hold on;
plot(rozmery(index_rustu + 1), p_values(index_rustu), ‘r*’, ‘MarkerSize’, 10);
hold off;
fprintf(‘Point where the p-value falls below the significance level: %d mmn’, rozmery(index_rustu + 1));
fprintf(‘P-value at this point: %fn’, p_values(index_rustu));
else
disp(‘No point found where the p-value falls below the significance level.’);
endHello everyone. I need to calculate the p-value for each sample with different dimensions and compare them with the reference value, which is the largest sample at 100 mm. I need to perform a one-sample t-test with a significance level of 0.05. Here is my code. I don’t know why it always outputs NaN for the 80 mm value. I would like to fix this.
My Code:
% Clear the workspace, command window, and close any open figures
clc;
clear all;
close all;
% Input data
data = [67.142880, 69.218820, 67.379050, 69.943850, 67.407470]; % Data values
rozmery = [100, 80, 60, 40, 20]; % Dimensions
reference_value = data(1); % Reference value
% Significance level
alpha = 0.05;
% Initialize an array to store p-values
p_values = zeros(1, length(data) – 1);
% Perform t-tests and calculate p-values for each subsequent data point
for i = 2:length(data)
% Perform a one-sample t-test
[~, p_values(i-1)] = ttest2(data(1:i-1), data(i), ‘Alpha’, alpha);
end
% Plot the graph
figure;
plot(rozmery(2:end), p_values, ‘-o’, ‘LineWidth’, 2); % Plot dimensions against p-values
xlabel(‘Dimensions (mm)’); % X-axis label
ylabel(‘P-values’); % Y-axis label
title(‘P-values vs Dimensions’); % Title of the plot
grid on; % Turn on the grid
% Add labels to the plot
for i = 2:length(rozmery)
text(rozmery(i), p_values(i-1), sprintf(‘(%d, %f)’, rozmery(i), p_values(i-1)),…
‘VerticalAlignment’, ‘bottom’, ‘HorizontalAlignment’, ‘left’);
% Add text annotations for each point on the plot
end
% Display the corresponding dimension values and p-values
for i = 2:length(rozmery)
fprintf(‘P-value for dimension %d mm: %fn’, rozmery(i), p_values(i-1));
end
% Find the point where the p-value falls below the significance level
index_rustu = find(p_values < alpha, 1);
% Display the point where the p-value falls below the significance level
if ~isempty(index_rustu)
hold on;
plot(rozmery(index_rustu + 1), p_values(index_rustu), ‘r*’, ‘MarkerSize’, 10);
hold off;
fprintf(‘Point where the p-value falls below the significance level: %d mmn’, rozmery(index_rustu + 1));
fprintf(‘P-value at this point: %fn’, p_values(index_rustu));
else
disp(‘No point found where the p-value falls below the significance level.’);
end Hello everyone. I need to calculate the p-value for each sample with different dimensions and compare them with the reference value, which is the largest sample at 100 mm. I need to perform a one-sample t-test with a significance level of 0.05. Here is my code. I don’t know why it always outputs NaN for the 80 mm value. I would like to fix this.
My Code:
% Clear the workspace, command window, and close any open figures
clc;
clear all;
close all;
% Input data
data = [67.142880, 69.218820, 67.379050, 69.943850, 67.407470]; % Data values
rozmery = [100, 80, 60, 40, 20]; % Dimensions
reference_value = data(1); % Reference value
% Significance level
alpha = 0.05;
% Initialize an array to store p-values
p_values = zeros(1, length(data) – 1);
% Perform t-tests and calculate p-values for each subsequent data point
for i = 2:length(data)
% Perform a one-sample t-test
[~, p_values(i-1)] = ttest2(data(1:i-1), data(i), ‘Alpha’, alpha);
end
% Plot the graph
figure;
plot(rozmery(2:end), p_values, ‘-o’, ‘LineWidth’, 2); % Plot dimensions against p-values
xlabel(‘Dimensions (mm)’); % X-axis label
ylabel(‘P-values’); % Y-axis label
title(‘P-values vs Dimensions’); % Title of the plot
grid on; % Turn on the grid
% Add labels to the plot
for i = 2:length(rozmery)
text(rozmery(i), p_values(i-1), sprintf(‘(%d, %f)’, rozmery(i), p_values(i-1)),…
‘VerticalAlignment’, ‘bottom’, ‘HorizontalAlignment’, ‘left’);
% Add text annotations for each point on the plot
end
% Display the corresponding dimension values and p-values
for i = 2:length(rozmery)
fprintf(‘P-value for dimension %d mm: %fn’, rozmery(i), p_values(i-1));
end
% Find the point where the p-value falls below the significance level
index_rustu = find(p_values < alpha, 1);
% Display the point where the p-value falls below the significance level
if ~isempty(index_rustu)
hold on;
plot(rozmery(index_rustu + 1), p_values(index_rustu), ‘r*’, ‘MarkerSize’, 10);
hold off;
fprintf(‘Point where the p-value falls below the significance level: %d mmn’, rozmery(index_rustu + 1));
fprintf(‘P-value at this point: %fn’, p_values(index_rustu));
else
disp(‘No point found where the p-value falls below the significance level.’);
end statistics, t-test MATLAB Answers — New Questions
triple nested integral with error “Arrays have incompatible sizes for this operation.”
Hi! I have a code in which there are three integrals, nested inside one another. These are the functions:
function integral_z = integral_z(z0, a, y, P, A, omega0, to)
fe = f_e(z0, P);
insideF0 = 2.*a.*(1+7.*(a.^2)).*(2*pi*P.nu/omega0).*(to.^(3/2)).*(z0.^(-1) + A.*(8.*to).^(-1/2).*a.^(-1).*y.^(-2).*(1-y.^(16/9))).^2;
integral_z = fe.*F0(insideF0);
end
function Integrand = Integrand(a, y, P, A, omega0, to)
z0_min = ((P.p-2)./(P.p-1))./(1-P.geratio.^(2-P.p));
z0_max = P.geratio.*z0_min;
% calling first integral
Integrand = ((a.^3).*((1+7.*(a.^2)).^(-2))).*integral(@(z0)integral_z(z0, a, y, P, A, omega0, to), z0_min, z0_max);
end
function IntegrandY = IntegrandY(y, P, A, omega0, to)
% calling second integral
IntegrandY = y.^3.*integral(@(a)Integrand(a, y, P, A, omega0, to), 0, 1);
end
and I call IntegrandY as follows:
% calling third integral
integral(@(y)IntegrandY(y, P, A, omega0, to),0,1);
But I get the following error:
Arrays have incompatible sizes for this operation.
Error in F_BM_Analytic_Cooling/integral_z (line 49)
insideF0 = 2.*a.*(1+7.*(a.^2)).*(2*pi*P.nu/omega0).*(to.^(3/2)).*(z0.^(-1) + A.*(8.*to).^(-1/2).*a.^(-1).*y.^(-2).*(1-y.^(16/9))).^2;
Error in F_BM_Analytic_Cooling>@(z0)integral_z(z0,a,y,P,A,omega0,to) (line 56)
Integrand = ((a.^3).*((1+7.*(a.^2)).^(-2))).*integral(@(z0)integral_z(z0, a, y, P, A, omega0, to), z0_min, z0_max);
Error in integralCalc/iterateScalarValued (line 323)
fx = FUN(t).*w;
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
Error in F_BM_Analytic_Cooling/Integrand (line 56)
Integrand = ((a.^3).*((1+7.*(a.^2)).^(-2))).*integral(@(z0)integral_z(z0, a, y, P, A, omega0, to), z0_min, z0_max);
Error in F_BM_Analytic_Cooling>@(a)Integrand(a,y,P,A,omega0,to) (line 60)
IntegrandY = y.^3.*integral(@(a)Integrand(a, y, P, A, omega0, to), 0, 1);
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
Error in F_BM_Analytic_Cooling/IntegrandY (line 60)
IntegrandY = y.^3.*integral(@(a)Integrand(a, y, P, A, omega0, to), 0, 1);
Error in F_BM_Analytic_Cooling>@(y)IntegrandY(y,P,A,omega0,to) (line 27)
int2 = integral(@(y)IntegrandY(y, P, A, omega0, to),0,1);
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
Error in F_BM_Analytic_Cooling (line 27)
int2 = integral(@(y)IntegrandY(y, P, A, omega0, to),0,1);
In order to find out more, I paused the code each time one of the functions is called. That showed me that the first time integral_z is called everything runs smoothly, and y, a and z0 all have the same size (1X150). Then, for a reason I don’t understand, integral_z is called a second time with the same y, a only with a different z0, of a different size, (1X90). I don’t understand why would integral_z be called again, and I’m really clueless as of what to do.
Any help would be greatly appriciated!Hi! I have a code in which there are three integrals, nested inside one another. These are the functions:
function integral_z = integral_z(z0, a, y, P, A, omega0, to)
fe = f_e(z0, P);
insideF0 = 2.*a.*(1+7.*(a.^2)).*(2*pi*P.nu/omega0).*(to.^(3/2)).*(z0.^(-1) + A.*(8.*to).^(-1/2).*a.^(-1).*y.^(-2).*(1-y.^(16/9))).^2;
integral_z = fe.*F0(insideF0);
end
function Integrand = Integrand(a, y, P, A, omega0, to)
z0_min = ((P.p-2)./(P.p-1))./(1-P.geratio.^(2-P.p));
z0_max = P.geratio.*z0_min;
% calling first integral
Integrand = ((a.^3).*((1+7.*(a.^2)).^(-2))).*integral(@(z0)integral_z(z0, a, y, P, A, omega0, to), z0_min, z0_max);
end
function IntegrandY = IntegrandY(y, P, A, omega0, to)
% calling second integral
IntegrandY = y.^3.*integral(@(a)Integrand(a, y, P, A, omega0, to), 0, 1);
end
and I call IntegrandY as follows:
% calling third integral
integral(@(y)IntegrandY(y, P, A, omega0, to),0,1);
But I get the following error:
Arrays have incompatible sizes for this operation.
Error in F_BM_Analytic_Cooling/integral_z (line 49)
insideF0 = 2.*a.*(1+7.*(a.^2)).*(2*pi*P.nu/omega0).*(to.^(3/2)).*(z0.^(-1) + A.*(8.*to).^(-1/2).*a.^(-1).*y.^(-2).*(1-y.^(16/9))).^2;
Error in F_BM_Analytic_Cooling>@(z0)integral_z(z0,a,y,P,A,omega0,to) (line 56)
Integrand = ((a.^3).*((1+7.*(a.^2)).^(-2))).*integral(@(z0)integral_z(z0, a, y, P, A, omega0, to), z0_min, z0_max);
Error in integralCalc/iterateScalarValued (line 323)
fx = FUN(t).*w;
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
Error in F_BM_Analytic_Cooling/Integrand (line 56)
Integrand = ((a.^3).*((1+7.*(a.^2)).^(-2))).*integral(@(z0)integral_z(z0, a, y, P, A, omega0, to), z0_min, z0_max);
Error in F_BM_Analytic_Cooling>@(a)Integrand(a,y,P,A,omega0,to) (line 60)
IntegrandY = y.^3.*integral(@(a)Integrand(a, y, P, A, omega0, to), 0, 1);
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
Error in F_BM_Analytic_Cooling/IntegrandY (line 60)
IntegrandY = y.^3.*integral(@(a)Integrand(a, y, P, A, omega0, to), 0, 1);
Error in F_BM_Analytic_Cooling>@(y)IntegrandY(y,P,A,omega0,to) (line 27)
int2 = integral(@(y)IntegrandY(y, P, A, omega0, to),0,1);
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
Error in F_BM_Analytic_Cooling (line 27)
int2 = integral(@(y)IntegrandY(y, P, A, omega0, to),0,1);
In order to find out more, I paused the code each time one of the functions is called. That showed me that the first time integral_z is called everything runs smoothly, and y, a and z0 all have the same size (1X150). Then, for a reason I don’t understand, integral_z is called a second time with the same y, a only with a different z0, of a different size, (1X90). I don’t understand why would integral_z be called again, and I’m really clueless as of what to do.
Any help would be greatly appriciated! Hi! I have a code in which there are three integrals, nested inside one another. These are the functions:
function integral_z = integral_z(z0, a, y, P, A, omega0, to)
fe = f_e(z0, P);
insideF0 = 2.*a.*(1+7.*(a.^2)).*(2*pi*P.nu/omega0).*(to.^(3/2)).*(z0.^(-1) + A.*(8.*to).^(-1/2).*a.^(-1).*y.^(-2).*(1-y.^(16/9))).^2;
integral_z = fe.*F0(insideF0);
end
function Integrand = Integrand(a, y, P, A, omega0, to)
z0_min = ((P.p-2)./(P.p-1))./(1-P.geratio.^(2-P.p));
z0_max = P.geratio.*z0_min;
% calling first integral
Integrand = ((a.^3).*((1+7.*(a.^2)).^(-2))).*integral(@(z0)integral_z(z0, a, y, P, A, omega0, to), z0_min, z0_max);
end
function IntegrandY = IntegrandY(y, P, A, omega0, to)
% calling second integral
IntegrandY = y.^3.*integral(@(a)Integrand(a, y, P, A, omega0, to), 0, 1);
end
and I call IntegrandY as follows:
% calling third integral
integral(@(y)IntegrandY(y, P, A, omega0, to),0,1);
But I get the following error:
Arrays have incompatible sizes for this operation.
Error in F_BM_Analytic_Cooling/integral_z (line 49)
insideF0 = 2.*a.*(1+7.*(a.^2)).*(2*pi*P.nu/omega0).*(to.^(3/2)).*(z0.^(-1) + A.*(8.*to).^(-1/2).*a.^(-1).*y.^(-2).*(1-y.^(16/9))).^2;
Error in F_BM_Analytic_Cooling>@(z0)integral_z(z0,a,y,P,A,omega0,to) (line 56)
Integrand = ((a.^3).*((1+7.*(a.^2)).^(-2))).*integral(@(z0)integral_z(z0, a, y, P, A, omega0, to), z0_min, z0_max);
Error in integralCalc/iterateScalarValued (line 323)
fx = FUN(t).*w;
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
Error in F_BM_Analytic_Cooling/Integrand (line 56)
Integrand = ((a.^3).*((1+7.*(a.^2)).^(-2))).*integral(@(z0)integral_z(z0, a, y, P, A, omega0, to), z0_min, z0_max);
Error in F_BM_Analytic_Cooling>@(a)Integrand(a,y,P,A,omega0,to) (line 60)
IntegrandY = y.^3.*integral(@(a)Integrand(a, y, P, A, omega0, to), 0, 1);
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
Error in F_BM_Analytic_Cooling/IntegrandY (line 60)
IntegrandY = y.^3.*integral(@(a)Integrand(a, y, P, A, omega0, to), 0, 1);
Error in F_BM_Analytic_Cooling>@(y)IntegrandY(y,P,A,omega0,to) (line 27)
int2 = integral(@(y)IntegrandY(y, P, A, omega0, to),0,1);
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
Error in F_BM_Analytic_Cooling (line 27)
int2 = integral(@(y)IntegrandY(y, P, A, omega0, to),0,1);
In order to find out more, I paused the code each time one of the functions is called. That showed me that the first time integral_z is called everything runs smoothly, and y, a and z0 all have the same size (1X150). Then, for a reason I don’t understand, integral_z is called a second time with the same y, a only with a different z0, of a different size, (1X90). I don’t understand why would integral_z be called again, and I’m really clueless as of what to do.
Any help would be greatly appriciated! integration, integral, arrays, function MATLAB Answers — New Questions