Category: News
Startups Assemble Virtual Conference Recap
Startups Assemble Virtual Conference Recap
Event Highlight: Panel Session
Event Highlight: Startup Showcase
Event Highlight: Founders’ Hub
Join Microsoft for Startups Founders’ Hub today!
Microsoft Tech Community – Latest Blogs –Read More
Small Signal Stability analysis using Single Machine Infinite Bus system
How do I set up state variables, input and output for my SMIB model on simulink so that I can be able to linearise it for eigenvalue analysis?How do I set up state variables, input and output for my SMIB model on simulink so that I can be able to linearise it for eigenvalue analysis? How do I set up state variables, input and output for my SMIB model on simulink so that I can be able to linearise it for eigenvalue analysis? small signal stability MATLAB Answers — New Questions
I am struggling trying to figure out this code I have it completed but I keep getting errors, can you help?
load(‘eegdata.mat’);
data = eegdata;
srate = 500;
N = size(data, 2); % Length of data on a channel; total number of data points
nchans = size(data, 1) ; % Number of channels, which is the size of the first dim of ‘data’
time = (0:N-1) / srate; % Time vector
ntrials = 10; % Number of trials
% Lowpass Filter ————–
% You will create the gaussian kernel here for low-pass filtering. Use
% a steepness value of 0.5 and kernel length of 15.
steepness = 0.5; % kernel steepness
kernelLength = 15; % kernel length
incr = 2*steepness/(kernelLength-1);
kernel = exp(-(-steepness:incr:steepness).^2);
kernel = kernel./sum(kernel); % normalize kernel
% Filtering
% Use a loop to go through the data on each channel and
% use the ‘conv’ function to convolve the data with the gaussian
% kernel you created above. Ensure that the output has the same
% length as the input data, using the ‘same’ option. The fdata matrix
% will store the filtered data.
for i = 1:nchans
fdata(i,:) = conv(data(i,:), kernel, ‘same’);
end
% FIGURE 1: Plot Raw and Filtered Channel Data
% Plot the raw and filtered data (‘data’ and ‘fdata’) for each channel
% separately, in the first and second columns. Modify the x/y labels and
% the plot titles as shown in the figure in the question prompt.
figure(‘Name’, ‘Channel Data’)
for i = 1:nchans
subplot(nchans, 2, (i-1)*2 + 1)
plot(time, data(i,:))
xlabel(‘Time (s)’)
ylabel(‘Amplitude’)
title([‘Raw Data – Channel ‘, num2str(i)])
subplot(nchans, 2, (i-1)*2 + 2)
plot(time, fdata(i,:))
xlabel(‘Time (s)’)
ylabel(‘Amplitude’)
title([‘Filtered Data – Channel ‘, num2str(i)])
end
% Epoch data ————–
% Epoch the data into epochs using the ‘reshape’ function.
% The number of epochs (trials) are indicated by the ‘ntrials’ variable.
% Data in each channel should be divided into ‘ntrials’ epochs and
% the resulting data should be stored in the ‘efdata’ matrix.
% The ‘efdata’ is a 3-dimensional matrix; with channels, data points, and trials
% as the dimensions, respectively.
efdata= reshape(fdata,nchans,[],ntrials);
% Average data across the epochs
% Calculate the mean data for each channel.
% You should take the average of all trials, separately for each channel.
% The ‘mean’ function allows you to indicate over which dimension
% should the mean be calculated. You should take the mean over trials.
mefdata = mean(efdata, 3);
eN = size(efdata, 2); % Calculate the length of a single epoch (number of data points in an epoch)
etime = 0:1/srate:(eN/srate)-1/srate; % Create the time vector for a single epoch
% Taper averaged epochs ————–
% As we discussed in class, edges in epoched data cause artifacts in
% frequency analysis. To avoid this problem, we will taper the data with
% a Hann window. Use the ‘hann’ function to create a hann window
% at the lenght of an epoch (you will need to transpose the output),
% then multiply the hann window with the averaged
% epoched data (‘mefdata’). Remember, this is an element-wise
% multiplication, meaning that each point in the hann window will be
% multiplied with the matching point in the data, separately for each
% channel (use ‘.*’). Store the tapered data matrix in ‘tmefdata’/
hanntaper = hann(eN); % Use the hann function and ‘eN’ as length. Transpose as well.
tmefdata = ‘mean(efdata, 3)’ .* ‘hann(eN)’ ; % multiply the mefdata with hanntaper. Use element-wise multiplication ‘.*’
% Frequency Analysis ————–
% Before you conduct the frequency analysis, go to the bottom of the script
% and follow the instructions to complete the ‘myFourier’ function. Once
% done, come back here to continue.
% Go through each channel and calculate the frequencies and powers for both
% the untapered (mefdata) and tapered (tmefdata) data.
for i=1:nchans
[mef_freqs(i,:),mef_pows(i,:)] = myFourier(mefdata(i,:)); % Left side is already done, complete the right side
[tmef_freqs(i,:),tmef_pows(i,:)] = myFourier(tmefdata(i,:)); % Left side is already done, complete the right side
end
% Time-Frequency Analysis————–
% Before you conduct the time-frequency analysis, go to the bottom of the
% script and follow the instructions to complete the ‘myMorlet’ function.
% Once done, come back here to continue.
% Let’s say we are interested in frequencies between 0 and 40 Hz
minFreq = 0;
maxFreq = 40;
% Calculate the frequency vectors and matching power values over time using
% the ‘myMorlet’ function. Remember, we don’t use the epoched data for frequency analysis
% First use the continous filtered data, ‘fdata’ for the transformation to
% the time-frequency domain, then epoch the t-f data.
for i=1:nchans
[tf_freqs{i}, tf_pows{i}] = myMorlet(fdata(i,:), srate, minFreq, maxFreq); % Only complete the right side. Use ‘fdata’, ‘srate’, ‘minFreq’ and ‘maxFreq’ inside myMorlet
end
nfreqs = size(tf_freqs{1},1); % The number of frequencies
etf_pows = zeros(nchans, nfreqs, eN, ntrials); % Initiate matrix for epoched t-f data
metf_pows = zeros(nchans, nfreqs, eN); % Initiate matrix for averaged epoched t-f data
% Epoch the t-f data and calculate the mean t-f data
% This part is already done, though inspect it to see how it was done
for i = 1:nchans % calculate etf_pows and metf_pows
etf_pows(i,:,:,:) = reshape(tf_pows{i}, nfreqs,[], ntrials);
metf_pows(i,:,:) = squeeze(mean(etf_pows(i,:,:,:),4));
end
% Plots
nC = 4; % Number of types of plots
% FIGURE 2
figure(‘Name’,’Analysis Results’, ‘Position’, [10 200 900 nC*200]) % Create figure 2, adjust its size
% Here you will create Figure 2, where averaged TD (time-domain), averaged untapered FD (frequency-domain),
% averaged Tapered FD, and the averaged TF (time-frequency domain) data are plotted, separately for each channel
% Use subplots in the loop to create the figure. The figure created should
% look like the one in the question (Figure 2).
for i = 1:nchans
subplot(nchans, nC, (i-1)*nC + 1) % Use ‘nchans’ and ‘nC’ variables to adjust the indices
plot(etime,mefdata(i,:)) % Plot epoch time vs mean epoched, filtered data.
title(‘Averaged Signal TD’)
xlim([min(etime), max(etime)]) % Use min and max etime for the range of x values
ylabel([‘Channel ‘, num2str(i)]) % The ylabel should show the channel number (see Fig. 2 in the question)
subplot(nchans, nC, (i-1)*nC + 2) % Use ‘nchans’ and ‘nC’ variables to adjust the indices
plot(tf_freqs{i}, tf_pows{i}) % Plots freqs vs pows for untapered data
title(‘Avg. Signal FD’)
xlim([minFreq, maxFreq]) % Use minFreq and maxFreq as limits
subplot(nchans, nC, (i-1)*nC + 3) % Use ‘nchans’ and ‘nC’ variables to adjust the indices
plot(tf_freqs{i}, tmefdata(i, :)) % Plots freqs vs pows for tapered data
title(‘Avg. Tapered Signal FD’)
xlim([minFreq, maxFreq]) % Use minFreq and maxFreq as limits
subplot(nchans,nC,(i-1)*nC + 4);
% Use etime, tf_freqs, and metf_pows for the contourf plot. Be careful
% about whether you use () or {} and the indices. Consider using the
% squeeze function as well. Number of contour levels is already set as
% 40, and ‘linecolor’ is set to ‘none’.
contourf(etime, squeeze(tf_freqs{i}), squeeze(metf_pows(i, :, :)),40,’linecolor’,’none’)
title(‘Signal TF’)
end
% Coherence Analysis
% Here you will study the coherence in the signal between pairs of
% channels.
% Initialize the cell array to store coherence results
cohRes = cell(nchans, nchans);
% FIGURE 3
figure(‘Name’,’Coherence Analysis’, ‘Position’, [10 200 800 800])
% Loop over each pair of channels
for i = 1:nchans
for j = (i+1):nchans
% Extract data for the current channel pair
chanA_data = data(i, :);
chanB_data = data(j, :);
% Perform spectral coherence analysis
% Check the ‘mscohere’ documentation. Use chanA_data and chanB_data
% for the two signals. Use the default window and nooverlap values
% (just put ‘[]’ to use the default values). Check frequencies 0 to
% 40. Use srate for the sampling rate.
[cohVals, cohFreqs] = mscohere(chanA_data, chanB_data, [], [], 0:40, srate);
% Store coherence results in the cell array
cohRes{i, j} = cohVals;
% Plot coherence results in subplots
subplot(nchans, nchans, (i-1)*nchans + j); % Cool indexing magic here
plot(cohFreqs, cohVals); % Plot coherence frequencies vs coherence values
xlabel(‘Frequency (Hz)’);
ylabel(‘Coherence’);
title([‘Chan. ‘, num2str(i), ‘ & ‘, num2str(j)]);
end
end
% My Fourier Transform Function
% The ‘myFourier’ function takes the signal and sampling rate as inputs
% and produces a vector frequencies and a vector of matching power values
% Use the ‘fft’ function to calculate the Fouerier coefficients.
function [freqs, pows] = myFourier(signal,srate)
n = length(signal); % length of signal
freqs = linspace(0, srate/2, n/2+1); % frequency vector
signalx = fft(signal); % conduct fft with the signal
pows = abs(signalx(1:n/2+1)).^2; % calculate power values based on the coefficients
end
% Morlet Convolution
% The ‘myMorlet’ function takes the signal, sampling rate, and min & max
% frequencies as inputs, and outputs the frequencies and matching powers
% over the time series. Use Matlab’s ‘cwt’ function with the ‘amor’ option
% to conduct a Morlet wavelet transofrmation. Use the ‘FrequencyLimits’
% option with ‘minFreq’ and ‘maxFreq’ as limits. Check the ‘cwt’
% documentation for info on how to use these options.
function [freqs, pows] = myMorlet(signal,srate,minFreq,maxFreq)
[coefs, freqs] = cwt(signal, ‘amor’, srate, ‘FrequencyLimits’, [minFreq, maxFreq]); % Use the ‘cwt’ function with the ‘amor’ option to calculate the coefficients and frequencies
pows =abs(coefs).^2; % Use the ‘abs’ function to calculate ampltitudes from ‘coefs’ and take its square to calculate power
endload(‘eegdata.mat’);
data = eegdata;
srate = 500;
N = size(data, 2); % Length of data on a channel; total number of data points
nchans = size(data, 1) ; % Number of channels, which is the size of the first dim of ‘data’
time = (0:N-1) / srate; % Time vector
ntrials = 10; % Number of trials
% Lowpass Filter ————–
% You will create the gaussian kernel here for low-pass filtering. Use
% a steepness value of 0.5 and kernel length of 15.
steepness = 0.5; % kernel steepness
kernelLength = 15; % kernel length
incr = 2*steepness/(kernelLength-1);
kernel = exp(-(-steepness:incr:steepness).^2);
kernel = kernel./sum(kernel); % normalize kernel
% Filtering
% Use a loop to go through the data on each channel and
% use the ‘conv’ function to convolve the data with the gaussian
% kernel you created above. Ensure that the output has the same
% length as the input data, using the ‘same’ option. The fdata matrix
% will store the filtered data.
for i = 1:nchans
fdata(i,:) = conv(data(i,:), kernel, ‘same’);
end
% FIGURE 1: Plot Raw and Filtered Channel Data
% Plot the raw and filtered data (‘data’ and ‘fdata’) for each channel
% separately, in the first and second columns. Modify the x/y labels and
% the plot titles as shown in the figure in the question prompt.
figure(‘Name’, ‘Channel Data’)
for i = 1:nchans
subplot(nchans, 2, (i-1)*2 + 1)
plot(time, data(i,:))
xlabel(‘Time (s)’)
ylabel(‘Amplitude’)
title([‘Raw Data – Channel ‘, num2str(i)])
subplot(nchans, 2, (i-1)*2 + 2)
plot(time, fdata(i,:))
xlabel(‘Time (s)’)
ylabel(‘Amplitude’)
title([‘Filtered Data – Channel ‘, num2str(i)])
end
% Epoch data ————–
% Epoch the data into epochs using the ‘reshape’ function.
% The number of epochs (trials) are indicated by the ‘ntrials’ variable.
% Data in each channel should be divided into ‘ntrials’ epochs and
% the resulting data should be stored in the ‘efdata’ matrix.
% The ‘efdata’ is a 3-dimensional matrix; with channels, data points, and trials
% as the dimensions, respectively.
efdata= reshape(fdata,nchans,[],ntrials);
% Average data across the epochs
% Calculate the mean data for each channel.
% You should take the average of all trials, separately for each channel.
% The ‘mean’ function allows you to indicate over which dimension
% should the mean be calculated. You should take the mean over trials.
mefdata = mean(efdata, 3);
eN = size(efdata, 2); % Calculate the length of a single epoch (number of data points in an epoch)
etime = 0:1/srate:(eN/srate)-1/srate; % Create the time vector for a single epoch
% Taper averaged epochs ————–
% As we discussed in class, edges in epoched data cause artifacts in
% frequency analysis. To avoid this problem, we will taper the data with
% a Hann window. Use the ‘hann’ function to create a hann window
% at the lenght of an epoch (you will need to transpose the output),
% then multiply the hann window with the averaged
% epoched data (‘mefdata’). Remember, this is an element-wise
% multiplication, meaning that each point in the hann window will be
% multiplied with the matching point in the data, separately for each
% channel (use ‘.*’). Store the tapered data matrix in ‘tmefdata’/
hanntaper = hann(eN); % Use the hann function and ‘eN’ as length. Transpose as well.
tmefdata = ‘mean(efdata, 3)’ .* ‘hann(eN)’ ; % multiply the mefdata with hanntaper. Use element-wise multiplication ‘.*’
% Frequency Analysis ————–
% Before you conduct the frequency analysis, go to the bottom of the script
% and follow the instructions to complete the ‘myFourier’ function. Once
% done, come back here to continue.
% Go through each channel and calculate the frequencies and powers for both
% the untapered (mefdata) and tapered (tmefdata) data.
for i=1:nchans
[mef_freqs(i,:),mef_pows(i,:)] = myFourier(mefdata(i,:)); % Left side is already done, complete the right side
[tmef_freqs(i,:),tmef_pows(i,:)] = myFourier(tmefdata(i,:)); % Left side is already done, complete the right side
end
% Time-Frequency Analysis————–
% Before you conduct the time-frequency analysis, go to the bottom of the
% script and follow the instructions to complete the ‘myMorlet’ function.
% Once done, come back here to continue.
% Let’s say we are interested in frequencies between 0 and 40 Hz
minFreq = 0;
maxFreq = 40;
% Calculate the frequency vectors and matching power values over time using
% the ‘myMorlet’ function. Remember, we don’t use the epoched data for frequency analysis
% First use the continous filtered data, ‘fdata’ for the transformation to
% the time-frequency domain, then epoch the t-f data.
for i=1:nchans
[tf_freqs{i}, tf_pows{i}] = myMorlet(fdata(i,:), srate, minFreq, maxFreq); % Only complete the right side. Use ‘fdata’, ‘srate’, ‘minFreq’ and ‘maxFreq’ inside myMorlet
end
nfreqs = size(tf_freqs{1},1); % The number of frequencies
etf_pows = zeros(nchans, nfreqs, eN, ntrials); % Initiate matrix for epoched t-f data
metf_pows = zeros(nchans, nfreqs, eN); % Initiate matrix for averaged epoched t-f data
% Epoch the t-f data and calculate the mean t-f data
% This part is already done, though inspect it to see how it was done
for i = 1:nchans % calculate etf_pows and metf_pows
etf_pows(i,:,:,:) = reshape(tf_pows{i}, nfreqs,[], ntrials);
metf_pows(i,:,:) = squeeze(mean(etf_pows(i,:,:,:),4));
end
% Plots
nC = 4; % Number of types of plots
% FIGURE 2
figure(‘Name’,’Analysis Results’, ‘Position’, [10 200 900 nC*200]) % Create figure 2, adjust its size
% Here you will create Figure 2, where averaged TD (time-domain), averaged untapered FD (frequency-domain),
% averaged Tapered FD, and the averaged TF (time-frequency domain) data are plotted, separately for each channel
% Use subplots in the loop to create the figure. The figure created should
% look like the one in the question (Figure 2).
for i = 1:nchans
subplot(nchans, nC, (i-1)*nC + 1) % Use ‘nchans’ and ‘nC’ variables to adjust the indices
plot(etime,mefdata(i,:)) % Plot epoch time vs mean epoched, filtered data.
title(‘Averaged Signal TD’)
xlim([min(etime), max(etime)]) % Use min and max etime for the range of x values
ylabel([‘Channel ‘, num2str(i)]) % The ylabel should show the channel number (see Fig. 2 in the question)
subplot(nchans, nC, (i-1)*nC + 2) % Use ‘nchans’ and ‘nC’ variables to adjust the indices
plot(tf_freqs{i}, tf_pows{i}) % Plots freqs vs pows for untapered data
title(‘Avg. Signal FD’)
xlim([minFreq, maxFreq]) % Use minFreq and maxFreq as limits
subplot(nchans, nC, (i-1)*nC + 3) % Use ‘nchans’ and ‘nC’ variables to adjust the indices
plot(tf_freqs{i}, tmefdata(i, :)) % Plots freqs vs pows for tapered data
title(‘Avg. Tapered Signal FD’)
xlim([minFreq, maxFreq]) % Use minFreq and maxFreq as limits
subplot(nchans,nC,(i-1)*nC + 4);
% Use etime, tf_freqs, and metf_pows for the contourf plot. Be careful
% about whether you use () or {} and the indices. Consider using the
% squeeze function as well. Number of contour levels is already set as
% 40, and ‘linecolor’ is set to ‘none’.
contourf(etime, squeeze(tf_freqs{i}), squeeze(metf_pows(i, :, :)),40,’linecolor’,’none’)
title(‘Signal TF’)
end
% Coherence Analysis
% Here you will study the coherence in the signal between pairs of
% channels.
% Initialize the cell array to store coherence results
cohRes = cell(nchans, nchans);
% FIGURE 3
figure(‘Name’,’Coherence Analysis’, ‘Position’, [10 200 800 800])
% Loop over each pair of channels
for i = 1:nchans
for j = (i+1):nchans
% Extract data for the current channel pair
chanA_data = data(i, :);
chanB_data = data(j, :);
% Perform spectral coherence analysis
% Check the ‘mscohere’ documentation. Use chanA_data and chanB_data
% for the two signals. Use the default window and nooverlap values
% (just put ‘[]’ to use the default values). Check frequencies 0 to
% 40. Use srate for the sampling rate.
[cohVals, cohFreqs] = mscohere(chanA_data, chanB_data, [], [], 0:40, srate);
% Store coherence results in the cell array
cohRes{i, j} = cohVals;
% Plot coherence results in subplots
subplot(nchans, nchans, (i-1)*nchans + j); % Cool indexing magic here
plot(cohFreqs, cohVals); % Plot coherence frequencies vs coherence values
xlabel(‘Frequency (Hz)’);
ylabel(‘Coherence’);
title([‘Chan. ‘, num2str(i), ‘ & ‘, num2str(j)]);
end
end
% My Fourier Transform Function
% The ‘myFourier’ function takes the signal and sampling rate as inputs
% and produces a vector frequencies and a vector of matching power values
% Use the ‘fft’ function to calculate the Fouerier coefficients.
function [freqs, pows] = myFourier(signal,srate)
n = length(signal); % length of signal
freqs = linspace(0, srate/2, n/2+1); % frequency vector
signalx = fft(signal); % conduct fft with the signal
pows = abs(signalx(1:n/2+1)).^2; % calculate power values based on the coefficients
end
% Morlet Convolution
% The ‘myMorlet’ function takes the signal, sampling rate, and min & max
% frequencies as inputs, and outputs the frequencies and matching powers
% over the time series. Use Matlab’s ‘cwt’ function with the ‘amor’ option
% to conduct a Morlet wavelet transofrmation. Use the ‘FrequencyLimits’
% option with ‘minFreq’ and ‘maxFreq’ as limits. Check the ‘cwt’
% documentation for info on how to use these options.
function [freqs, pows] = myMorlet(signal,srate,minFreq,maxFreq)
[coefs, freqs] = cwt(signal, ‘amor’, srate, ‘FrequencyLimits’, [minFreq, maxFreq]); % Use the ‘cwt’ function with the ‘amor’ option to calculate the coefficients and frequencies
pows =abs(coefs).^2; % Use the ‘abs’ function to calculate ampltitudes from ‘coefs’ and take its square to calculate power
end load(‘eegdata.mat’);
data = eegdata;
srate = 500;
N = size(data, 2); % Length of data on a channel; total number of data points
nchans = size(data, 1) ; % Number of channels, which is the size of the first dim of ‘data’
time = (0:N-1) / srate; % Time vector
ntrials = 10; % Number of trials
% Lowpass Filter ————–
% You will create the gaussian kernel here for low-pass filtering. Use
% a steepness value of 0.5 and kernel length of 15.
steepness = 0.5; % kernel steepness
kernelLength = 15; % kernel length
incr = 2*steepness/(kernelLength-1);
kernel = exp(-(-steepness:incr:steepness).^2);
kernel = kernel./sum(kernel); % normalize kernel
% Filtering
% Use a loop to go through the data on each channel and
% use the ‘conv’ function to convolve the data with the gaussian
% kernel you created above. Ensure that the output has the same
% length as the input data, using the ‘same’ option. The fdata matrix
% will store the filtered data.
for i = 1:nchans
fdata(i,:) = conv(data(i,:), kernel, ‘same’);
end
% FIGURE 1: Plot Raw and Filtered Channel Data
% Plot the raw and filtered data (‘data’ and ‘fdata’) for each channel
% separately, in the first and second columns. Modify the x/y labels and
% the plot titles as shown in the figure in the question prompt.
figure(‘Name’, ‘Channel Data’)
for i = 1:nchans
subplot(nchans, 2, (i-1)*2 + 1)
plot(time, data(i,:))
xlabel(‘Time (s)’)
ylabel(‘Amplitude’)
title([‘Raw Data – Channel ‘, num2str(i)])
subplot(nchans, 2, (i-1)*2 + 2)
plot(time, fdata(i,:))
xlabel(‘Time (s)’)
ylabel(‘Amplitude’)
title([‘Filtered Data – Channel ‘, num2str(i)])
end
% Epoch data ————–
% Epoch the data into epochs using the ‘reshape’ function.
% The number of epochs (trials) are indicated by the ‘ntrials’ variable.
% Data in each channel should be divided into ‘ntrials’ epochs and
% the resulting data should be stored in the ‘efdata’ matrix.
% The ‘efdata’ is a 3-dimensional matrix; with channels, data points, and trials
% as the dimensions, respectively.
efdata= reshape(fdata,nchans,[],ntrials);
% Average data across the epochs
% Calculate the mean data for each channel.
% You should take the average of all trials, separately for each channel.
% The ‘mean’ function allows you to indicate over which dimension
% should the mean be calculated. You should take the mean over trials.
mefdata = mean(efdata, 3);
eN = size(efdata, 2); % Calculate the length of a single epoch (number of data points in an epoch)
etime = 0:1/srate:(eN/srate)-1/srate; % Create the time vector for a single epoch
% Taper averaged epochs ————–
% As we discussed in class, edges in epoched data cause artifacts in
% frequency analysis. To avoid this problem, we will taper the data with
% a Hann window. Use the ‘hann’ function to create a hann window
% at the lenght of an epoch (you will need to transpose the output),
% then multiply the hann window with the averaged
% epoched data (‘mefdata’). Remember, this is an element-wise
% multiplication, meaning that each point in the hann window will be
% multiplied with the matching point in the data, separately for each
% channel (use ‘.*’). Store the tapered data matrix in ‘tmefdata’/
hanntaper = hann(eN); % Use the hann function and ‘eN’ as length. Transpose as well.
tmefdata = ‘mean(efdata, 3)’ .* ‘hann(eN)’ ; % multiply the mefdata with hanntaper. Use element-wise multiplication ‘.*’
% Frequency Analysis ————–
% Before you conduct the frequency analysis, go to the bottom of the script
% and follow the instructions to complete the ‘myFourier’ function. Once
% done, come back here to continue.
% Go through each channel and calculate the frequencies and powers for both
% the untapered (mefdata) and tapered (tmefdata) data.
for i=1:nchans
[mef_freqs(i,:),mef_pows(i,:)] = myFourier(mefdata(i,:)); % Left side is already done, complete the right side
[tmef_freqs(i,:),tmef_pows(i,:)] = myFourier(tmefdata(i,:)); % Left side is already done, complete the right side
end
% Time-Frequency Analysis————–
% Before you conduct the time-frequency analysis, go to the bottom of the
% script and follow the instructions to complete the ‘myMorlet’ function.
% Once done, come back here to continue.
% Let’s say we are interested in frequencies between 0 and 40 Hz
minFreq = 0;
maxFreq = 40;
% Calculate the frequency vectors and matching power values over time using
% the ‘myMorlet’ function. Remember, we don’t use the epoched data for frequency analysis
% First use the continous filtered data, ‘fdata’ for the transformation to
% the time-frequency domain, then epoch the t-f data.
for i=1:nchans
[tf_freqs{i}, tf_pows{i}] = myMorlet(fdata(i,:), srate, minFreq, maxFreq); % Only complete the right side. Use ‘fdata’, ‘srate’, ‘minFreq’ and ‘maxFreq’ inside myMorlet
end
nfreqs = size(tf_freqs{1},1); % The number of frequencies
etf_pows = zeros(nchans, nfreqs, eN, ntrials); % Initiate matrix for epoched t-f data
metf_pows = zeros(nchans, nfreqs, eN); % Initiate matrix for averaged epoched t-f data
% Epoch the t-f data and calculate the mean t-f data
% This part is already done, though inspect it to see how it was done
for i = 1:nchans % calculate etf_pows and metf_pows
etf_pows(i,:,:,:) = reshape(tf_pows{i}, nfreqs,[], ntrials);
metf_pows(i,:,:) = squeeze(mean(etf_pows(i,:,:,:),4));
end
% Plots
nC = 4; % Number of types of plots
% FIGURE 2
figure(‘Name’,’Analysis Results’, ‘Position’, [10 200 900 nC*200]) % Create figure 2, adjust its size
% Here you will create Figure 2, where averaged TD (time-domain), averaged untapered FD (frequency-domain),
% averaged Tapered FD, and the averaged TF (time-frequency domain) data are plotted, separately for each channel
% Use subplots in the loop to create the figure. The figure created should
% look like the one in the question (Figure 2).
for i = 1:nchans
subplot(nchans, nC, (i-1)*nC + 1) % Use ‘nchans’ and ‘nC’ variables to adjust the indices
plot(etime,mefdata(i,:)) % Plot epoch time vs mean epoched, filtered data.
title(‘Averaged Signal TD’)
xlim([min(etime), max(etime)]) % Use min and max etime for the range of x values
ylabel([‘Channel ‘, num2str(i)]) % The ylabel should show the channel number (see Fig. 2 in the question)
subplot(nchans, nC, (i-1)*nC + 2) % Use ‘nchans’ and ‘nC’ variables to adjust the indices
plot(tf_freqs{i}, tf_pows{i}) % Plots freqs vs pows for untapered data
title(‘Avg. Signal FD’)
xlim([minFreq, maxFreq]) % Use minFreq and maxFreq as limits
subplot(nchans, nC, (i-1)*nC + 3) % Use ‘nchans’ and ‘nC’ variables to adjust the indices
plot(tf_freqs{i}, tmefdata(i, :)) % Plots freqs vs pows for tapered data
title(‘Avg. Tapered Signal FD’)
xlim([minFreq, maxFreq]) % Use minFreq and maxFreq as limits
subplot(nchans,nC,(i-1)*nC + 4);
% Use etime, tf_freqs, and metf_pows for the contourf plot. Be careful
% about whether you use () or {} and the indices. Consider using the
% squeeze function as well. Number of contour levels is already set as
% 40, and ‘linecolor’ is set to ‘none’.
contourf(etime, squeeze(tf_freqs{i}), squeeze(metf_pows(i, :, :)),40,’linecolor’,’none’)
title(‘Signal TF’)
end
% Coherence Analysis
% Here you will study the coherence in the signal between pairs of
% channels.
% Initialize the cell array to store coherence results
cohRes = cell(nchans, nchans);
% FIGURE 3
figure(‘Name’,’Coherence Analysis’, ‘Position’, [10 200 800 800])
% Loop over each pair of channels
for i = 1:nchans
for j = (i+1):nchans
% Extract data for the current channel pair
chanA_data = data(i, :);
chanB_data = data(j, :);
% Perform spectral coherence analysis
% Check the ‘mscohere’ documentation. Use chanA_data and chanB_data
% for the two signals. Use the default window and nooverlap values
% (just put ‘[]’ to use the default values). Check frequencies 0 to
% 40. Use srate for the sampling rate.
[cohVals, cohFreqs] = mscohere(chanA_data, chanB_data, [], [], 0:40, srate);
% Store coherence results in the cell array
cohRes{i, j} = cohVals;
% Plot coherence results in subplots
subplot(nchans, nchans, (i-1)*nchans + j); % Cool indexing magic here
plot(cohFreqs, cohVals); % Plot coherence frequencies vs coherence values
xlabel(‘Frequency (Hz)’);
ylabel(‘Coherence’);
title([‘Chan. ‘, num2str(i), ‘ & ‘, num2str(j)]);
end
end
% My Fourier Transform Function
% The ‘myFourier’ function takes the signal and sampling rate as inputs
% and produces a vector frequencies and a vector of matching power values
% Use the ‘fft’ function to calculate the Fouerier coefficients.
function [freqs, pows] = myFourier(signal,srate)
n = length(signal); % length of signal
freqs = linspace(0, srate/2, n/2+1); % frequency vector
signalx = fft(signal); % conduct fft with the signal
pows = abs(signalx(1:n/2+1)).^2; % calculate power values based on the coefficients
end
% Morlet Convolution
% The ‘myMorlet’ function takes the signal, sampling rate, and min & max
% frequencies as inputs, and outputs the frequencies and matching powers
% over the time series. Use Matlab’s ‘cwt’ function with the ‘amor’ option
% to conduct a Morlet wavelet transofrmation. Use the ‘FrequencyLimits’
% option with ‘minFreq’ and ‘maxFreq’ as limits. Check the ‘cwt’
% documentation for info on how to use these options.
function [freqs, pows] = myMorlet(signal,srate,minFreq,maxFreq)
[coefs, freqs] = cwt(signal, ‘amor’, srate, ‘FrequencyLimits’, [minFreq, maxFreq]); % Use the ‘cwt’ function with the ‘amor’ option to calculate the coefficients and frequencies
pows =abs(coefs).^2; % Use the ‘abs’ function to calculate ampltitudes from ‘coefs’ and take its square to calculate power
end help MATLAB Answers — New Questions
Dynamically generate a simulink block
I was wondering if it was possible to dynamically generate a Simulink block (subsystem with mask) based on the parameters entered: for example being able to decide how many inputs/outputs it has by inserting the number as a parameter (as happens for the mux and demux blocks) but also by changing how the subsystem is made internally.I was wondering if it was possible to dynamically generate a Simulink block (subsystem with mask) based on the parameters entered: for example being able to decide how many inputs/outputs it has by inserting the number as a parameter (as happens for the mux and demux blocks) but also by changing how the subsystem is made internally. I was wondering if it was possible to dynamically generate a Simulink block (subsystem with mask) based on the parameters entered: for example being able to decide how many inputs/outputs it has by inserting the number as a parameter (as happens for the mux and demux blocks) but also by changing how the subsystem is made internally. subsystem, mask, dynamically generated block MATLAB Answers — New Questions
Hide Class template in Microsoft Teams
Hello,
Our tenant is an education-tenant, where we have Academic A1 and A5-licenses.
When our users are creating a new team in Teams they are met with this view:
Is it possible to hide the templates connected to education, such as “Class”, “Professional learning..”, “Staff” and “Other” from the view when a user is to create a Team? Only a basic template would be needed.
As far as I can see, you can add/hide other templates via the Admin Centre, but not specifically the core templates such as “Class”. Is there a way to do this?
Hello, Our tenant is an education-tenant, where we have Academic A1 and A5-licenses. When our users are creating a new team in Teams they are met with this view:Is it possible to hide the templates connected to education, such as “Class”, “Professional learning..”, “Staff” and “Other” from the view when a user is to create a Team? Only a basic template would be needed. As far as I can see, you can add/hide other templates via the Admin Centre, but not specifically the core templates such as “Class”. Is there a way to do this? Read More
I am getting the following error when I run my script: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatc
I’m running the following script in Matlab and getting the following error message:
h = h + (1/6) (k1 + 2k2 + 2*k3 + k4);
↑
Invalid expression. When calling a function or indexing a variable, use parentheses.
Otherwise, check for mismatched delimiters.
Could you please assist me with clearing the error.
% Given data
h0 = 4.84; % Initial height (m)
t0 = 0; % Initial time (hrs)
tf = 15; % Final time (hrs)
h_target = 3.5; % Target height (m) after 3.5 hrs
% Function representing the differential equation
dhdt = @(t, h, k) k * sqrt(h);
% Runge-Kutta method
h = h0;
t = t0;
k = 0; % To be determined
tolerance = 1e-6;
while t < 3.5
k1 = dhdt(t, h, k);
k2 = dhdt(t + 0.5, h + 0.5 * k1, k);
k3 = dhdt(t + 0.5, h + 0.5 * k2, k);
k4 = dhdt(t + 1, h + k3, k);
h = h + (1/6) * (k1 + 2*k2 + 2*k3 + k4);
t = t + 1;
k = (h_target – h) / (tf – t); % Adjusting k based on target height
end
% After 3.5 hours
fprintf(‘Height after 3.5 hours: %.4f mn’, h);
% Continue solving until tf
while t < tf
k1 = dhdt(t, h, k);
k2 = dhdt(t + 0.5, h + 0.5 * k1, k);
k3 = dhdt(t + 0.5, h + 0.5 * k2, k);
k4 = dhdt(t + 1, h + k3, k);
h = h + (1/6) * (k1 + 2*k2 + 2*k3 + k4);
t = t + 1;
end
% Display the final height
fprintf(‘Height after %.1f hours: %.4f mn’, tf, h);I’m running the following script in Matlab and getting the following error message:
h = h + (1/6) (k1 + 2k2 + 2*k3 + k4);
↑
Invalid expression. When calling a function or indexing a variable, use parentheses.
Otherwise, check for mismatched delimiters.
Could you please assist me with clearing the error.
% Given data
h0 = 4.84; % Initial height (m)
t0 = 0; % Initial time (hrs)
tf = 15; % Final time (hrs)
h_target = 3.5; % Target height (m) after 3.5 hrs
% Function representing the differential equation
dhdt = @(t, h, k) k * sqrt(h);
% Runge-Kutta method
h = h0;
t = t0;
k = 0; % To be determined
tolerance = 1e-6;
while t < 3.5
k1 = dhdt(t, h, k);
k2 = dhdt(t + 0.5, h + 0.5 * k1, k);
k3 = dhdt(t + 0.5, h + 0.5 * k2, k);
k4 = dhdt(t + 1, h + k3, k);
h = h + (1/6) * (k1 + 2*k2 + 2*k3 + k4);
t = t + 1;
k = (h_target – h) / (tf – t); % Adjusting k based on target height
end
% After 3.5 hours
fprintf(‘Height after 3.5 hours: %.4f mn’, h);
% Continue solving until tf
while t < tf
k1 = dhdt(t, h, k);
k2 = dhdt(t + 0.5, h + 0.5 * k1, k);
k3 = dhdt(t + 0.5, h + 0.5 * k2, k);
k4 = dhdt(t + 1, h + k3, k);
h = h + (1/6) * (k1 + 2*k2 + 2*k3 + k4);
t = t + 1;
end
% Display the final height
fprintf(‘Height after %.1f hours: %.4f mn’, tf, h); I’m running the following script in Matlab and getting the following error message:
h = h + (1/6) (k1 + 2k2 + 2*k3 + k4);
↑
Invalid expression. When calling a function or indexing a variable, use parentheses.
Otherwise, check for mismatched delimiters.
Could you please assist me with clearing the error.
% Given data
h0 = 4.84; % Initial height (m)
t0 = 0; % Initial time (hrs)
tf = 15; % Final time (hrs)
h_target = 3.5; % Target height (m) after 3.5 hrs
% Function representing the differential equation
dhdt = @(t, h, k) k * sqrt(h);
% Runge-Kutta method
h = h0;
t = t0;
k = 0; % To be determined
tolerance = 1e-6;
while t < 3.5
k1 = dhdt(t, h, k);
k2 = dhdt(t + 0.5, h + 0.5 * k1, k);
k3 = dhdt(t + 0.5, h + 0.5 * k2, k);
k4 = dhdt(t + 1, h + k3, k);
h = h + (1/6) * (k1 + 2*k2 + 2*k3 + k4);
t = t + 1;
k = (h_target – h) / (tf – t); % Adjusting k based on target height
end
% After 3.5 hours
fprintf(‘Height after 3.5 hours: %.4f mn’, h);
% Continue solving until tf
while t < tf
k1 = dhdt(t, h, k);
k2 = dhdt(t + 0.5, h + 0.5 * k1, k);
k3 = dhdt(t + 0.5, h + 0.5 * k2, k);
k4 = dhdt(t + 1, h + k3, k);
h = h + (1/6) * (k1 + 2*k2 + 2*k3 + k4);
t = t + 1;
end
% Display the final height
fprintf(‘Height after %.1f hours: %.4f mn’, tf, h); first order ode MATLAB Answers — New Questions
matlab parallel computing toolbox is not working
I am using Matlab R2023a and R2023b with parallel computing toolbox on Mac OS Ventura 13.5.1 (22G90). It used to work well, but without reason, the parallel stops working. I seems it just use one core as the order of the processed files is reversed with regard to that feed into the for loop.
I tried to re-install parallel computing toolbox. It worked for one time, but then stops working even when I re-install the toolbox again. I also tried re-install matlab. Still not working.
When I run parpool:
>> parpool
Unrecognized function or variable ‘parpool’.
Or start parpool by clicking Start Parallel Pool:
Unrecognized function or variable ‘parallel.internal.ui.PoolHelper.startPool’.
This used to work, but failed without any changes in search path or new toolboxes.
Could anyone give a hint?I am using Matlab R2023a and R2023b with parallel computing toolbox on Mac OS Ventura 13.5.1 (22G90). It used to work well, but without reason, the parallel stops working. I seems it just use one core as the order of the processed files is reversed with regard to that feed into the for loop.
I tried to re-install parallel computing toolbox. It worked for one time, but then stops working even when I re-install the toolbox again. I also tried re-install matlab. Still not working.
When I run parpool:
>> parpool
Unrecognized function or variable ‘parpool’.
Or start parpool by clicking Start Parallel Pool:
Unrecognized function or variable ‘parallel.internal.ui.PoolHelper.startPool’.
This used to work, but failed without any changes in search path or new toolboxes.
Could anyone give a hint? I am using Matlab R2023a and R2023b with parallel computing toolbox on Mac OS Ventura 13.5.1 (22G90). It used to work well, but without reason, the parallel stops working. I seems it just use one core as the order of the processed files is reversed with regard to that feed into the for loop.
I tried to re-install parallel computing toolbox. It worked for one time, but then stops working even when I re-install the toolbox again. I also tried re-install matlab. Still not working.
When I run parpool:
>> parpool
Unrecognized function or variable ‘parpool’.
Or start parpool by clicking Start Parallel Pool:
Unrecognized function or variable ‘parallel.internal.ui.PoolHelper.startPool’.
This used to work, but failed without any changes in search path or new toolboxes.
Could anyone give a hint? parallel computing toolbox MATLAB Answers — New Questions
Fix to frequent “Application not responding” for MATLAB on the Mac
I am frequently having the Mac version of MATLAB lock up in "Application not responding", leading to "Force quit" in the Finder or Terminal. I have found no specific way to reproducibly make this happen, but it tends to occur after a number of traditional (Java based) figures are opened and closed. The problem occurs in several hand-coded graphical interfaces (not GUIDE, pre-App Designer) that have worked for years, and it seems to be getting worse.
As far as I can tell, this is a Mac-specific problem. I thought it was confined to Silicon machines, but the same behavior occurs for Silicon machines running the Intel version of MATLAB as well as Intel machines. I see it a lot in releases 2023b and 2024a, even after updates, but one of my users reports problems as far back as 2021a. I know that I see more and more frequency Java errors in the command window in recent years, and these often preceed MATLAB freezing altogether. Just today, I’ve observed the problem when using Corretto 11 and 17 (only 2024a supports this), and I’m pretty sure it happens with Corretto 8.
A Javascript version (uifigure) of the same graphical interfaces presumably would not experience this problem, but it would take an enormous amount of work to transition these program over from legacy code. Despite what the Bug Fixes say in updates and new releases, the problem has not been fixed. Any ideas?I am frequently having the Mac version of MATLAB lock up in "Application not responding", leading to "Force quit" in the Finder or Terminal. I have found no specific way to reproducibly make this happen, but it tends to occur after a number of traditional (Java based) figures are opened and closed. The problem occurs in several hand-coded graphical interfaces (not GUIDE, pre-App Designer) that have worked for years, and it seems to be getting worse.
As far as I can tell, this is a Mac-specific problem. I thought it was confined to Silicon machines, but the same behavior occurs for Silicon machines running the Intel version of MATLAB as well as Intel machines. I see it a lot in releases 2023b and 2024a, even after updates, but one of my users reports problems as far back as 2021a. I know that I see more and more frequency Java errors in the command window in recent years, and these often preceed MATLAB freezing altogether. Just today, I’ve observed the problem when using Corretto 11 and 17 (only 2024a supports this), and I’m pretty sure it happens with Corretto 8.
A Javascript version (uifigure) of the same graphical interfaces presumably would not experience this problem, but it would take an enormous amount of work to transition these program over from legacy code. Despite what the Bug Fixes say in updates and new releases, the problem has not been fixed. Any ideas? I am frequently having the Mac version of MATLAB lock up in "Application not responding", leading to "Force quit" in the Finder or Terminal. I have found no specific way to reproducibly make this happen, but it tends to occur after a number of traditional (Java based) figures are opened and closed. The problem occurs in several hand-coded graphical interfaces (not GUIDE, pre-App Designer) that have worked for years, and it seems to be getting worse.
As far as I can tell, this is a Mac-specific problem. I thought it was confined to Silicon machines, but the same behavior occurs for Silicon machines running the Intel version of MATLAB as well as Intel machines. I see it a lot in releases 2023b and 2024a, even after updates, but one of my users reports problems as far back as 2021a. I know that I see more and more frequency Java errors in the command window in recent years, and these often preceed MATLAB freezing altogether. Just today, I’ve observed the problem when using Corretto 11 and 17 (only 2024a supports this), and I’m pretty sure it happens with Corretto 8.
A Javascript version (uifigure) of the same graphical interfaces presumably would not experience this problem, but it would take an enormous amount of work to transition these program over from legacy code. Despite what the Bug Fixes say in updates and new releases, the problem has not been fixed. Any ideas? mac, not responding MATLAB Answers — New Questions
Combined Doses in Simfunction
Hi. I have the code below with two different target for dosing. I plan to use different values (input in the code for different doses) for thoses targets and use simFunction. How should I modify the code. Thanks
setup; %(I build the model here)
params ={‘dose_amount’,’dose_amounta’};
Titles = {‘plasma’, ‘lung’,’liver’,’kidney’,’muscle’, ‘skin’,’adipose’,’bone’, ‘brain’,’heart’,’spleen’,’pancreas’,’tumor’};
obs = {‘V_tum’};
for i = 1:length(Titles)
Title = Titles{i};
entryAb =[‘CAb_’ Title];
entryADC =[‘CADC_’ Title];
entryPL =[‘CPL_’ Title];
entryPLun =[‘CPLun_’ Title];
obs = [obs;entryAb;entryADC;entryPL;entryPLun];
end
dis=linspace(5,70,numTumors);
for tumNum = 1:numTumors
entryTVR ={sprintf(‘TVR_tum%d’,tumNum)};
entryAb ={sprintf(‘Ab_tum%d’,tumNum)};
entryADC ={sprintf(‘ADC_tum%d’,tumNum)};
entryPL ={sprintf(‘PL_tum%d’,tumNum)};
entryPLun ={sprintf(‘PLun_tum%d’,tumNum)};
obs = [obs;entryTVR; entryAb;entryADC;entryPL;entryPLun];
end
input = [0.5 0;0.5 0.5]*1E6*sbioselect(model, ‘Name’,’BW’).value/sbioselect(model, ‘Name’,’MW_ADC’).value;
sfxn = createSimFunction(model, params, obs, {‘plasma.ADC_plasma’,’plasma.Ab_plasma’},’UseParallel’,true,’AutoAccelerate’,false);
doseTable = getTable(d1);
doseTable1 = getTable(d2);
doseTables = [doseTable, doseTable1];
simData = sfxn(input,configsetObj.StopTime,doseTables);
%% Doses
d1 = sbiodose(‘d1’, ‘repeat’);
d1.Amount = ‘dose_amount’;
d1.AmountUnits = ‘nanomole’;
d1.Interval = ‘dose_interval’;
d1.RepeatCount = ‘dose_repeat’;
d1.TargetName = ‘plasma.ADC_plasma’;
d1.StartTime = 0;
d1.TimeUnits=configsetObj.TimeUnits;
d2 = sbiodose(‘d2’, ‘repeat’);
d2.Amount = ‘dose_amounta’;
d2.AmountUnits = ‘nanomole’;
d2.Interval = ‘dose_intervala’;
d2.RepeatCount = ‘dose_repeata’;
d2.TargetName = ‘plasma.Ab_plasma’;
d2.StartTime = 0;
d2.TimeUnits=configsetObj.TimeUnits;Hi. I have the code below with two different target for dosing. I plan to use different values (input in the code for different doses) for thoses targets and use simFunction. How should I modify the code. Thanks
setup; %(I build the model here)
params ={‘dose_amount’,’dose_amounta’};
Titles = {‘plasma’, ‘lung’,’liver’,’kidney’,’muscle’, ‘skin’,’adipose’,’bone’, ‘brain’,’heart’,’spleen’,’pancreas’,’tumor’};
obs = {‘V_tum’};
for i = 1:length(Titles)
Title = Titles{i};
entryAb =[‘CAb_’ Title];
entryADC =[‘CADC_’ Title];
entryPL =[‘CPL_’ Title];
entryPLun =[‘CPLun_’ Title];
obs = [obs;entryAb;entryADC;entryPL;entryPLun];
end
dis=linspace(5,70,numTumors);
for tumNum = 1:numTumors
entryTVR ={sprintf(‘TVR_tum%d’,tumNum)};
entryAb ={sprintf(‘Ab_tum%d’,tumNum)};
entryADC ={sprintf(‘ADC_tum%d’,tumNum)};
entryPL ={sprintf(‘PL_tum%d’,tumNum)};
entryPLun ={sprintf(‘PLun_tum%d’,tumNum)};
obs = [obs;entryTVR; entryAb;entryADC;entryPL;entryPLun];
end
input = [0.5 0;0.5 0.5]*1E6*sbioselect(model, ‘Name’,’BW’).value/sbioselect(model, ‘Name’,’MW_ADC’).value;
sfxn = createSimFunction(model, params, obs, {‘plasma.ADC_plasma’,’plasma.Ab_plasma’},’UseParallel’,true,’AutoAccelerate’,false);
doseTable = getTable(d1);
doseTable1 = getTable(d2);
doseTables = [doseTable, doseTable1];
simData = sfxn(input,configsetObj.StopTime,doseTables);
%% Doses
d1 = sbiodose(‘d1’, ‘repeat’);
d1.Amount = ‘dose_amount’;
d1.AmountUnits = ‘nanomole’;
d1.Interval = ‘dose_interval’;
d1.RepeatCount = ‘dose_repeat’;
d1.TargetName = ‘plasma.ADC_plasma’;
d1.StartTime = 0;
d1.TimeUnits=configsetObj.TimeUnits;
d2 = sbiodose(‘d2’, ‘repeat’);
d2.Amount = ‘dose_amounta’;
d2.AmountUnits = ‘nanomole’;
d2.Interval = ‘dose_intervala’;
d2.RepeatCount = ‘dose_repeata’;
d2.TargetName = ‘plasma.Ab_plasma’;
d2.StartTime = 0;
d2.TimeUnits=configsetObj.TimeUnits; Hi. I have the code below with two different target for dosing. I plan to use different values (input in the code for different doses) for thoses targets and use simFunction. How should I modify the code. Thanks
setup; %(I build the model here)
params ={‘dose_amount’,’dose_amounta’};
Titles = {‘plasma’, ‘lung’,’liver’,’kidney’,’muscle’, ‘skin’,’adipose’,’bone’, ‘brain’,’heart’,’spleen’,’pancreas’,’tumor’};
obs = {‘V_tum’};
for i = 1:length(Titles)
Title = Titles{i};
entryAb =[‘CAb_’ Title];
entryADC =[‘CADC_’ Title];
entryPL =[‘CPL_’ Title];
entryPLun =[‘CPLun_’ Title];
obs = [obs;entryAb;entryADC;entryPL;entryPLun];
end
dis=linspace(5,70,numTumors);
for tumNum = 1:numTumors
entryTVR ={sprintf(‘TVR_tum%d’,tumNum)};
entryAb ={sprintf(‘Ab_tum%d’,tumNum)};
entryADC ={sprintf(‘ADC_tum%d’,tumNum)};
entryPL ={sprintf(‘PL_tum%d’,tumNum)};
entryPLun ={sprintf(‘PLun_tum%d’,tumNum)};
obs = [obs;entryTVR; entryAb;entryADC;entryPL;entryPLun];
end
input = [0.5 0;0.5 0.5]*1E6*sbioselect(model, ‘Name’,’BW’).value/sbioselect(model, ‘Name’,’MW_ADC’).value;
sfxn = createSimFunction(model, params, obs, {‘plasma.ADC_plasma’,’plasma.Ab_plasma’},’UseParallel’,true,’AutoAccelerate’,false);
doseTable = getTable(d1);
doseTable1 = getTable(d2);
doseTables = [doseTable, doseTable1];
simData = sfxn(input,configsetObj.StopTime,doseTables);
%% Doses
d1 = sbiodose(‘d1’, ‘repeat’);
d1.Amount = ‘dose_amount’;
d1.AmountUnits = ‘nanomole’;
d1.Interval = ‘dose_interval’;
d1.RepeatCount = ‘dose_repeat’;
d1.TargetName = ‘plasma.ADC_plasma’;
d1.StartTime = 0;
d1.TimeUnits=configsetObj.TimeUnits;
d2 = sbiodose(‘d2’, ‘repeat’);
d2.Amount = ‘dose_amounta’;
d2.AmountUnits = ‘nanomole’;
d2.Interval = ‘dose_intervala’;
d2.RepeatCount = ‘dose_repeata’;
d2.TargetName = ‘plasma.Ab_plasma’;
d2.StartTime = 0;
d2.TimeUnits=configsetObj.TimeUnits; combined doses in simfunction MATLAB Answers — New Questions
Parfor+for+if+if How to calculate variable form last if
See my code
parfor i = 1:n
for j=1:m
if some_condition(i)
if some_condition(i)
t=do_something(i);
b = [b;t];
end
end
end…
end
I want all b values to get out from the parSee my code
parfor i = 1:n
for j=1:m
if some_condition(i)
if some_condition(i)
t=do_something(i);
b = [b;t];
end
end
end…
end
I want all b values to get out from the par See my code
parfor i = 1:n
for j=1:m
if some_condition(i)
if some_condition(i)
t=do_something(i);
b = [b;t];
end
end
end…
end
I want all b values to get out from the par par+if+for MATLAB Answers — New Questions
Why does the for loop show the graph of the last plot?
Hi everyone.
My code is:
for i=46:52
plot(x,y1(:,i))
title("Title 1")
xlabel("xlabel1")
ylabel("ylabel1")
plot(x,y2(:,i))
title("Title 2")
xlabel("xlabel2")
ylabel("ylabel2")
end
Here x is a vector and y1, y2 are matrix. I intend to plot 14 different graphs of line (not in single figure, so didn’t use hold on). But matlab executes only plot(x,y2(:,52)) and its title and labels. I would be grateful if someone could explain the reasoning.Hi everyone.
My code is:
for i=46:52
plot(x,y1(:,i))
title("Title 1")
xlabel("xlabel1")
ylabel("ylabel1")
plot(x,y2(:,i))
title("Title 2")
xlabel("xlabel2")
ylabel("ylabel2")
end
Here x is a vector and y1, y2 are matrix. I intend to plot 14 different graphs of line (not in single figure, so didn’t use hold on). But matlab executes only plot(x,y2(:,52)) and its title and labels. I would be grateful if someone could explain the reasoning. Hi everyone.
My code is:
for i=46:52
plot(x,y1(:,i))
title("Title 1")
xlabel("xlabel1")
ylabel("ylabel1")
plot(x,y2(:,i))
title("Title 2")
xlabel("xlabel2")
ylabel("ylabel2")
end
Here x is a vector and y1, y2 are matrix. I intend to plot 14 different graphs of line (not in single figure, so didn’t use hold on). But matlab executes only plot(x,y2(:,52)) and its title and labels. I would be grateful if someone could explain the reasoning. for loop, plot MATLAB Answers — New Questions
エクセル画面が縮小してしまう
コントロールキーを押すと勝手に縮小してしまい、ショートカットが使えず困っています。
古い記事ではマウスが鯨飲とのことでしたが、マウスの電源を切っても変わらず縮小してしまいます。
解決方法をご指示ください。
コントロールキーを押すと勝手に縮小してしまい、ショートカットが使えず困っています。古い記事ではマウスが鯨飲とのことでしたが、マウスの電源を切っても変わらず縮小してしまいます。解決方法をご指示ください。 Read More
AI Semantic Search for Your Website with Azure Cosmos DB | E-commerce
Build low-latency recommendation engines with Azure Cosmos DB and OpenAI. Elevate user experience with vector-based semantic search, going beyond traditional keyword limitations to deliver personalized recommendations in real-time. With pre-trained models stored in Cosmos DB, tailor product predictions based on user interactions and preferences. Explore the power of augmented vector search for optimized results prioritized by relevance.
Kirill Gavrylyuk, Azure Cosmos DB General Manager, shows how to build recommendation systems with limitless scalability, leveraging pre-computed vectors and collaborative filtering for next-level, real-time insights.
Build low-latency recommendation engines.
Use Azure Cosmos DB and Azure OpenAI Service, and get started.
Elevate search functionality with vector-based semantic search.
Discover relevant items with user intent. Check it out.
Personalized product predictions
Generate predictions based on user and product interactions. See how it works in Azure Cosmos DB.
Watch our video here:
QUICK LINKS:
00:00 — Build a low latency recommendation engine
00:59 — Keyword search
01:46 — Vector-based semantic search
02:39 — Vector search built-in to Cosmos DB
03:56 — Model training
05:18 — Code for product predictions
06:02 — Test code for product prediction
06:39 — Augmented vector search
08:23 — Test code for augmented vector search
09:16 — Wrap up
Link References
Walk through an example at https://aka.ms/CosmosDBvectorSample
Try out Cosmos DB for MongoDB for free at https://aka.ms/TryC4M
Unfamiliar with Microsoft Mechanics?
As Microsoft’s official video series for IT, you can watch and share valuable content and demos of current and upcoming tech from the people who build it at Microsoft.
Subscribe to our YouTube: https://www.youtube.com/c/MicrosoftMechanicsSeries
Talk with other IT Pros, join us on the Microsoft Tech Community: https://techcommunity.microsoft.com/t5/microsoft-mechanics-blog/bg-p/MicrosoftMechanicsBlog
Watch or listen from anywhere, subscribe to our podcast: https://microsoftmechanics.libsyn.com/podcast
Keep getting this insider knowledge, join us on social:
Follow us on Twitter: https://twitter.com/MSFTMechanics
Share knowledge on LinkedIn: https://www.linkedin.com/company/microsoft-mechanics/
Enjoy us on Instagram: https://www.instagram.com/msftmechanics/
Loosen up with us on TikTok: https://www.tiktok.com/@msftmechanics
Video Transcript:
-Imagine finding your next purchase just by describing what you want to do, using natural language, with results returned in real-time, like asking for everything you’ll need to climb Mount Kilimanjaro that links directly to the appropriate items in your catalog to return the results for you to consider in just a matter of milliseconds, along with a just-in-time recommendation for items you are statistically likely to purchase.
-Now, as a developer, building a next-level and low-latency recommendation engine for distributed apps like this is not as difficult as you may think: We’ll use a combination of the vCore-based Azure Cosmos DB for MongoDB along with Azure OpenAI to generate vector embeddings and Cosmos DB’s built-in vector search for super fast similarity lookups over conversational data.
-And we’ll use a popular collaborative filtering model, Alternating Least Squares, ALS, in PySpark for learned and predictive recommendations. To show you what’s possible, let’s first look at the experience without AI and Vector Search. This is our e-commerce website, specializing in winter outdoor sports equipment.
-I’ll start with a classic text-based keyword search and type snowboards here in our text box and press Enter. And as you’d expect, I get a results page with a few snowboards. But what if I don’t know exactly what I want? Or maybe I want something very specific that is not in our keyword index.
-This time, I’ll try something different. I’ll type, “I want to snowboard like an Olympic champion.” And as you can see, this yields zero results. As you’ve probably experienced, keyword search works well when words or text strings are found in a database or search index, but it cannot apply semantic meaning.
-Let me now show you the difference with vector-based semantic search. I’ll type the same query as before, “I want to snowboard like an Olympic champion.” And here you can see I get a page of results. The very first result is a Shaun White snowboard from the three-time Olympic champion.
-In this case, we’re combining the power of our predictive recommendation model, ALS, along with the results from Cosmos DB’s built-in vector search, and Azure OpenAI GPT-4 for personalization of the response. And to keep me engaged and to stop me from clicking away, if I click on the Shaun White snowboard here, I’m also presented with a list of other products that I might like based on my preferences, my location, similarity between items, and user ratings. More on that in a moment.
-And as you saw, this happens in real time without delays that could make me hit the back button. Speed and relevance of results is important here, which is why Cosmos DB with its single digit millisecond latency and built-in vector search for semantic similarity is such an advantage. Let me explain how it works.
-First on the backend, for data in your database, we use a helper function that calls Azure OpenAI’s text embedding 3 model to automatically generate vector embeddings in real time as data is ingested into Cosmos DB. Think of embeddings as a coordinate-like way to refer to chunks of data in your database. And later, those are used for lookups.
-Then in the app frontend, when a user performs a search, their search string is also converted to a vector embedding by Azure OpenAI, and the lookup will try to find the dimensionally closest matches between the search string embedding and the embeddings in the product database. We then use the ALS model that has been trained on data, including the user’s purchase history, products entries in the database, and their ratings to re-rank the results by likelihood of purchase with collaborative filtering.
-This is then presented to the Azure OpenAI GPT-4 arge language model to generate a conversational response. And because vector search is built-in to Azure Cosmos DB, you don’t have to move the data to a separate vector database. Let me show you the steps to build this recommendation engine, first by looking at model training.
-This is where you’ll want to do the predictions ahead of time; store them in Cosmos DB and use them for real-time personalized recommendations. We’ll use the ALS model from the PySpark package to make our recommendations Now we’ll skip over some of the configuration setup and get right into the model. We’ve split the data so 80% was used to train the model, and 20% was used to evaluate how well it performs.
-And then we created an ALS model and configured it to train multiple different models so we could choose the one with the best parameters. The training itself takes a while, so we skipped that here to have a fully trained model. Now we’ve picked the best model and see that it has a root mean square error of 0.64. This means that, on average, we would expect it to be about 0.64 off the predicted rating, which in our case ends up being less than 10%. Not too bad.
-Then we used the model to make predictions for all of our users, and all of the products they have not rated before, and saved those to Cosmos DB. This way when we look up predictions for specific users, we can simply do a point read with the user ID to retrieve the predictions from Cosmos DB in under 10 milliseconds. Now, let’s look at the code for product predictions based on specific users and the products they’re viewing.
-This function takes the current user ID and the product ID from the product page that the user has opened and returns the user’s predicted products. The first step is to execute this point read for this user’s product predictions. Next, we need to remove the current product if it is one of the predicted products for this user. This is an important step as we don’t want to display a recommendation for the same product they’re actively looking at.
-Finally, we will fetch the product details to display to the user for each of the product predictions. And add the ratings for each product to the resulting list. Then return the list to the user. And now with the code complete for our function, let’s test it out. Here I have some values to feed into the function we’ve defined above.
-This includes user_id, product_id for the Shaun White snowboard we saw earlier, and we’ll return 10 results just so you can see a more complete list. Let’s run the function. And here you can see the recommended products. Notice the ratings on the right-hand side are in descending order. The higher the rating, the stronger the prediction If you remember, this list is what we saw on the right side of the screen when we clicked on the Shaun White snowboard.
-Now we’ll move on to our augmented vector search where we can again use these calculated predictions to improve the results based on what the user is most likely to buy. I’ll show what that code looks like. The first step is to generate vector embeddings from the user’s search text. Here we’re using our helper function to generate Azure OpenAI embeddings.
-Next, we execute a point read to grab all of the predicted products for the user. And this time, we’ll return every product so we can have a more complete set of results from our vector search. This is what we will use to perform our filtered vector search in Cosmos DB, so we’ll pass a list of product IDs to the $in operator for our vector query. Hybrid queries like this is an advantage of using a database with built-in vector search.
-Now it’s time for the vector search itself. This takes the array of embeddings from the user’s search and the filter criteria of predicted products. Then in my projection, I’ll return the entire product document, as well as the similarity score that I’ll show you in a minute. Next, after the vector search executes, I want to add in the prediction rating for that user to each product in my results. And our last step is to rank the results.
-As I mentioned, we want to return the top result from our vector search, which will have the highest similarity score. Then order the remaining results by the prediction rating for each of the remaining products. So I’ll remove the top vector search result, then sort the remaining results by their rating, then re-insert the top vector result back at the top of the list. And after all that, we can return the results to the user.
-With all the logic coded for our augmented semantic search to provide the best result for the user’s query and top-rated additional products, we can now test it out. I’ll use the same user_id I showed in the web app before, And I’ll also use the same text for the search we used earlier. Let’s run the cell. And notice how the top result is our Shaun White snowboard.
-This, of course, has the highest similarity score in our results. Coincidentally, it also has the highest rating too. The rest of the ratings are in descending order, but similarity scores are not. This is because of the sorting we did earlier to prioritize the order of the list based on rating as the highest prediction to buy, which is why these results are not all snowboards.
-And these are the results that we saw on the website when we enabled vector search. And with that, I’ve shown you the power of using pre-computed vectors in Azure Cosmos DB, combined with collaborative filtering and large language models for generative AI to help you build next-level, real-time recommendation systems of limitless scale.
-You can walk through this entire example yourself; we’ve published the eShop and our notebook on GitHub at aka.ms/CosmosDBvectorSample And you can try out Cosmos DB for MongoDB for free. Check out our quickstart at aka.ms/TryC4M. Keep watching Microsoft Mechanics for the latest updates. and thank you for watching!
Microsoft Tech Community – Latest Blogs –Read More
Parpool won’t start anymore
All of the sudden parpool will not start. After hours of trying it does not succeed.
It has run without problems for months and months. I usually run the ‘local’ profile
Only changes made recently, was addition of new Win 10 user, and addition of a startup.m file for the original user (otherwise matlab would also f*** up starting properly.
Computer has been restarted thrice, but matlab can’t start parpool.
Any clues?
I also can’t validate the local profile. It gets stuck in createJob (second task)All of the sudden parpool will not start. After hours of trying it does not succeed.
It has run without problems for months and months. I usually run the ‘local’ profile
Only changes made recently, was addition of new Win 10 user, and addition of a startup.m file for the original user (otherwise matlab would also f*** up starting properly.
Computer has been restarted thrice, but matlab can’t start parpool.
Any clues?
I also can’t validate the local profile. It gets stuck in createJob (second task) All of the sudden parpool will not start. After hours of trying it does not succeed.
It has run without problems for months and months. I usually run the ‘local’ profile
Only changes made recently, was addition of new Win 10 user, and addition of a startup.m file for the original user (otherwise matlab would also f*** up starting properly.
Computer has been restarted thrice, but matlab can’t start parpool.
Any clues?
I also can’t validate the local profile. It gets stuck in createJob (second task) parpool MATLAB Answers — New Questions
I need Pressurized Water Reactor (PWR) steam generator matlab code so if anyone has please help me. Thanks
I need Pressurized Water Reactor (PWR) steam generator matlab code so if anyone has please help me. I want to analyse PWR in detail. ThanksI need Pressurized Water Reactor (PWR) steam generator matlab code so if anyone has please help me. I want to analyse PWR in detail. Thanks I need Pressurized Water Reactor (PWR) steam generator matlab code so if anyone has please help me. I want to analyse PWR in detail. Thanks nuclear, steam generator, steam, pwr, pressurized water reactor MATLAB Answers — New Questions
What’s the correct syntax to set-up discrete convolution ?
I am trying to generate a 1-D discrete convolution data-set but I keep getting NaN values. I am wondering what’s going wrong. I want to convolve the function "differentiated_green" with the function "f" with respect to the variable "x".
These are the common parameters needed for complete definition of both the functions:
M = 0.5; alpha = log(2)/2; epsilon = 0.5; f = 1/30; omega = 2*pi*f; c_inf = 340; k = omega/c_inf; t = 270; nodes = 401;
y = 0;
x_start = -200; x_end = 200;
length = x_end – x_start;
x = linspace(x_start,x_end,nodes);
This is the definition of the function "f":
f = epsilon * exp( -alpha * x.^2);
This is the definition of the function "differentiated_green":
A = omega/( 4 * (c_inf^2)*sqrt(1-M^2));
B = besselh(0, (k*x)/(1-M^2));
C = exp( -1i*((M*k*x)/(1-M^2)) – (1i*omega*t));
differentiated_Green = (A * B) .* C;
The function "differentiated_green" is a complex value due to the presence of Hankel function in "B" and the exponential term "C". Since I want to convolve this function’s real values with the function "f", these are the commands I am using:
p = conv(real(differentiated_Green),f,’same’);
These commands are giving me NaN values and I am trying to understand what’s going wrong. Can someone please point out to me where I should troubleshoot ?I am trying to generate a 1-D discrete convolution data-set but I keep getting NaN values. I am wondering what’s going wrong. I want to convolve the function "differentiated_green" with the function "f" with respect to the variable "x".
These are the common parameters needed for complete definition of both the functions:
M = 0.5; alpha = log(2)/2; epsilon = 0.5; f = 1/30; omega = 2*pi*f; c_inf = 340; k = omega/c_inf; t = 270; nodes = 401;
y = 0;
x_start = -200; x_end = 200;
length = x_end – x_start;
x = linspace(x_start,x_end,nodes);
This is the definition of the function "f":
f = epsilon * exp( -alpha * x.^2);
This is the definition of the function "differentiated_green":
A = omega/( 4 * (c_inf^2)*sqrt(1-M^2));
B = besselh(0, (k*x)/(1-M^2));
C = exp( -1i*((M*k*x)/(1-M^2)) – (1i*omega*t));
differentiated_Green = (A * B) .* C;
The function "differentiated_green" is a complex value due to the presence of Hankel function in "B" and the exponential term "C". Since I want to convolve this function’s real values with the function "f", these are the commands I am using:
p = conv(real(differentiated_Green),f,’same’);
These commands are giving me NaN values and I am trying to understand what’s going wrong. Can someone please point out to me where I should troubleshoot ? I am trying to generate a 1-D discrete convolution data-set but I keep getting NaN values. I am wondering what’s going wrong. I want to convolve the function "differentiated_green" with the function "f" with respect to the variable "x".
These are the common parameters needed for complete definition of both the functions:
M = 0.5; alpha = log(2)/2; epsilon = 0.5; f = 1/30; omega = 2*pi*f; c_inf = 340; k = omega/c_inf; t = 270; nodes = 401;
y = 0;
x_start = -200; x_end = 200;
length = x_end – x_start;
x = linspace(x_start,x_end,nodes);
This is the definition of the function "f":
f = epsilon * exp( -alpha * x.^2);
This is the definition of the function "differentiated_green":
A = omega/( 4 * (c_inf^2)*sqrt(1-M^2));
B = besselh(0, (k*x)/(1-M^2));
C = exp( -1i*((M*k*x)/(1-M^2)) – (1i*omega*t));
differentiated_Green = (A * B) .* C;
The function "differentiated_green" is a complex value due to the presence of Hankel function in "B" and the exponential term "C". Since I want to convolve this function’s real values with the function "f", these are the commands I am using:
p = conv(real(differentiated_Green),f,’same’);
These commands are giving me NaN values and I am trying to understand what’s going wrong. Can someone please point out to me where I should troubleshoot ? convolution MATLAB Answers — New Questions
Liste déroulante
Bonjour Monsieur,
Je voulais savoir comment rechercher un élément dans une liste déroulante basée sur un tableau dans excel.
Merci pour la réponse
Bonjour Monsieur, Je voulais savoir comment rechercher un élément dans une liste déroulante basée sur un tableau dans excel. Merci pour la réponse Read More
how to change width and space in barplot?
Dear all,
can someone tell me if its possible to change the width of the bars in a barplot (so that they are wider) and obtain some space between the bars (so that I have the same but bigger space across all bars) while keeping the position of the xticks fixed relative to the bars? For example, I have the xticks = 0,5,10,15… so that the 6th bar is exactly at xtick 5, the 11th bar at xtick 10 and so on. I’m trying to keep this while increasing the barwidth and barspacing. But maybe barwidth and barspacing are not optimal for this exercise? Can anyone tell me what I can do?
Thank you very much for your help!Dear all,
can someone tell me if its possible to change the width of the bars in a barplot (so that they are wider) and obtain some space between the bars (so that I have the same but bigger space across all bars) while keeping the position of the xticks fixed relative to the bars? For example, I have the xticks = 0,5,10,15… so that the 6th bar is exactly at xtick 5, the 11th bar at xtick 10 and so on. I’m trying to keep this while increasing the barwidth and barspacing. But maybe barwidth and barspacing are not optimal for this exercise? Can anyone tell me what I can do?
Thank you very much for your help! Dear all,
can someone tell me if its possible to change the width of the bars in a barplot (so that they are wider) and obtain some space between the bars (so that I have the same but bigger space across all bars) while keeping the position of the xticks fixed relative to the bars? For example, I have the xticks = 0,5,10,15… so that the 6th bar is exactly at xtick 5, the 11th bar at xtick 10 and so on. I’m trying to keep this while increasing the barwidth and barspacing. But maybe barwidth and barspacing are not optimal for this exercise? Can anyone tell me what I can do?
Thank you very much for your help! bar barplot size space width barwidth barspace MATLAB Answers — New Questions
Excel stepped formula
Hi,
I hope someone can assist me with a formula to apply to a large dataset. Volumes are currently both produced and sold simultaneously, with the price per hour fluctuating. The objective is to sell the volumes produced at the highest available price on the day that it gets produced. However, there is a limit to the volumes that can be sold on an hourly basis. Therefore, the formula should consider the daily volumes and aim to sell them at the highest prices available throughout the day.
Hi,I hope someone can assist me with a formula to apply to a large dataset. Volumes are currently both produced and sold simultaneously, with the price per hour fluctuating. The objective is to sell the volumes produced at the highest available price on the day that it gets produced. However, there is a limit to the volumes that can be sold on an hourly basis. Therefore, the formula should consider the daily volumes and aim to sell them at the highest prices available throughout the day. Read More
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