https://es.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2019-06-26T22:37:30Ztag:es.mathworks.com,2005:Question/4690812019-06-26T21:47:19Z2019-06-26T22:37:30ZMatlab Eigenvalue/Vector wrong?!I am trying to find eigenvalues and vectors of following matrix.
Lsr=[0.0397796877172068 0.0138619531470359 0.0138619531468867 ;
0.0138619531470345 0.0397796877174583 0.0138619531469220;
0.0138619531468881 0.0138619531469388 0.0397796877171021]
[t,el]=eig(Lsr)
But when I reconstruct the matrix with:
X=t*el*t'
I get
X=[0.0403022792872612 0.0124347611687027 0.0147665535551808
0.0124347611687027 0.0406842881257273 0.0143845447169696
0.0147665535551808 0.0143845447169696 0.0383524957387787]
Which is totally off!
Any idea?Meysam Ahmadihttps://es.mathworks.com/matlabcentral/profile/authors/6120434-meysam-ahmaditag:es.mathworks.com,2005:Question/4690752019-06-26T21:08:33Z2019-06-26T22:29:02ZHow do I export a vector to workspace in simulink?I'm trying to model a household appliance in simulink. When the simulation ends, I need the model to output a vector to the workspace which contains power loads corresponding to simulation times. I've started with trying to implement as simple a model as I can, shown below.
The idea here is to just send simulation time to a function which appends the simulation time to a vector containing all simulation times. Basically, if the simulation stop time is 10, what I want from this model is AllTimes = [1, 2, 3, ... 10].
I've set the model to run an initialization function, which contains the following:
times = [];
The MATLAB function block contains the following:
function times = fcn(currentTime)
times = [times, currentTime];
times = time;
Simulink complains that:
The issue, as I understand it, is that "time" is declared outside fcn's scope. I've tried the following tweaks to fix this:
function times = fcn(currentTime)
if ~exist('vect')
vect = [];
end
times = currentTime;
function times = fcn(currentTime)
times = evalin('base', [times, currentTime]);
times = currentTime;
function times = fcn(currentTime)
assignin('base', times, [times, currentTime])
times = currentTime;
However, none of these have worked.
I also tried importing the function times from the workspace and passing it as an argument to fcn, like so:
function times = fcn(currentTime, times)
times = [times, currentTime];
times = currentTime;
However, this throws the error:
Unfortunately, I have very limited knowledge of MATLAB and even less knowledge of simulink. If anyone has any advice I would very much appreciate help.Shiloh Greerhttps://es.mathworks.com/matlabcentral/profile/authors/13498832-shiloh-greertag:es.mathworks.com,2005:Question/4690652019-06-26T20:05:00Z2019-06-26T22:28:11ZFor loop with really big matrix Hi all,
I am searching through a big matrix file (>800mb) and tried to loop through that matrix but it take a massive amount of time. I wonder if are there any method to run a simple for loop in this "big data" matrix. My code is at belown
clearvars;
load('landorocean_250_W.mat')
tA_world = tall(A_world);
tx_world = tall(x_world);
ty_world = tall(y_world);
[m_1,n_1]=size(A_world);
for i=1:m_1
for j=1:n_1
if gather(tA_world(i,j) == -32768)
island_250m_1(i,j)=0;
else
island_250m_1(i,j)=1;
end
end
end
Thank you for your time,
Sincerely, Trung Ngohttps://es.mathworks.com/matlabcentral/profile/authors/8932832-trung-ngotag:es.mathworks.com,2005:Question/4690772019-06-26T21:23:57Z2019-06-26T22:12:27ZModify text in a columnDear all, I want to modify just the first column of a file, removing the letters and keeping the numbers. The columns contain string like d200n-h. How it is possible?
Thanks,
MarcoMarco Settehttps://es.mathworks.com/matlabcentral/profile/authors/12996838-marco-settetag:es.mathworks.com,2005:Question/4685942019-06-24T11:32:08Z2019-06-26T22:11:24ZHow can i build a 3 phase inverter with simscape, which the output voltage with rise and fall time?How can i build a 3 phase inverter with simscape, which the output voltage with rise and fall time?
Normally the IGBT block are idea,l so the output voltage is just a step.Mingyuan Sunhttps://es.mathworks.com/matlabcentral/profile/authors/10485123-mingyuan-suntag:es.mathworks.com,2005:Question/4690832019-06-26T22:02:12Z2019-06-26T22:10:43ZData extract from graph.I have a plot I created in matlab using excel data. I would like my code to provide a Y value for the X value that I provide. Is this possible? Please note that i cannot look for the Y value, the code should automatically assign the Y value from the graph for provided X value.
Thanks for the Help.Vikas Vasudevanhttps://es.mathworks.com/matlabcentral/profile/authors/15247653-vikas-vasudevantag:es.mathworks.com,2005:Question/4690792019-06-26T21:32:25Z2019-06-26T22:07:50ZKinect V2 Depth ChangesHi All,
I am currently working with the Kinect V2 to develop a method of tracking respiratory motion.
How can I model and plot the depth changes over time? From looking into the array the depth image stores, the depth seems to be an index between the height and width.
For simplicity I want to plot the depth changes of a 5x5 pixel square in the center of the screen over 300 frames, so roughly 10 seconds. (I'll change the frequency to fixed 10 Hz later) but right now i'm stuck on the basics.
Any help would be appreciated!
Thank you in advance.Anthony Fotihttps://es.mathworks.com/matlabcentral/profile/authors/6690508-anthony-fotitag:es.mathworks.com,2005:Question/4650572019-06-01T10:05:19Z2019-06-26T22:07:10ZHow to change maxfun evals in fsolve 'levenberg-marquardt' algorith. I am using f solve to get the solution of a non linear system equation but i get the error:
Solver stopped prematurely.
fsolve stopped because it exceeded the function evaluation limit,
options.MaxFunEvals = 3500 (the default value).
I am trying to manual change the limit by coding:
options = optimoptions(@fsolve,'Algorithm','levenberg-marquardt','MaxFunEvals',15000)
as per manual but with no luck.
Can you help me? Morevoer is is "bad sign" for the stability of the system that the itterations are not enough to solve it?Michael Gkouvakishttps://es.mathworks.com/matlabcentral/profile/authors/14800261-michael-gkouvakistag:es.mathworks.com,2005:Question/4687932019-06-25T11:31:13Z2019-06-26T22:05:42ZBlank plot in matlabhello can you please help me?? when i type this code i only get a balnk plot
i don`t know where is my mistake
the code
sigma0=0;
el= 0.5;
L= 1 ;
h= 0.5 ;
a= 1;
N= 3;
g=10;
rho=1000;
Z0=0;
t=0:0.01:5;
x=0:0.02:el;
y=0:0.02:L;
[X,Y]=meshgrid (x,y);
sigma=0;
T=3*pi/4;
for n=0:N
for m=0:N
A=pi*((m/el)^(2)+(n/L)^(2))^(0.5);
B=(g*A+(sigma/rho)*A^3)*atan(A*h);
C=B^(0.5);
Z=a*cos(C.*T).*cos((m*pi/el).*X).*cos((n*pi/L).*Y);
Zs=Z0+Z;
Z0=Zs;
end
end
m=3;
n=4;
A=pi*((m/el)^(2)+(n/L)^(2))^(0.5);
B0=(g*A+(sigma0./rho)*A^3)*atan(A*h);
C0=(B0.^(0.5));
Z0=(a.*cos(C0.*T)).*cos((m*pi/el).*X).*(cos((n*pi/L).*Y));
figure
subplot(221)
plot(t,length(Z0));
xlabel(' temps s');
ylabel(' élévation z(x,y)y');
title(' sans tension superficielle');
legend('sigma0')MOUNIBA REDAHhttps://es.mathworks.com/matlabcentral/profile/authors/15717627-mouniba-redahtag:es.mathworks.com,2005:Question/4690782019-06-26T21:24:41Z2019-06-26T22:05:40ZExtract rows with a range of valuesI have two tables. The first table (tab1) has column with ids. We call it ID. The second table (tab2) also has ids which is called ID as well. I am trying to extract all the rows in tab2 that has at least one match of ID from tab1. Following is what I have tried:
rev_table=tab2(tab1.ID,:);
Could someone help please?Syeda Amberinhttps://es.mathworks.com/matlabcentral/profile/authors/12017818-syeda-amberintag:es.mathworks.com,2005:Question/912182013-10-23T13:57:38Z2019-06-26T21:57:41ZCapture mouse location beyond screen coordinates Hi Jan,
I am writing you because you seem to answer almost every question I search for. Now that my search is not producing anything, I thought I might go ahead and try you now . My question regards mouse position. I am currently coding a program where I would like the mouse to 1)allow the mouse to go off-screen and 2)record its positions while there (and invisible).
The reason I need this functionality: I am programming a game where I am trying to make the user move the mouse a lot to produce just a little movement in an object. That means for a large change in mouse position, I am only allowing the object they are controlling to move a bit. Because large position changes will result only in small motion changes, the resolution of the screen does not provide me with the range I need to give the user the ability to move the object in a wide range, as I would like. I want them to be able to laboriously drag the mouse through a large range on the table to produce the movement.
The problem, I cannot find any way to track the mouse in a range that is larger than the screen resolution, either with MATLAB or with Psychtoolbox.
Any ideas?
Thanks,
ChachaChachahttps://es.mathworks.com/matlabcentral/profile/authors/4655262-chachatag:es.mathworks.com,2005:Question/4690822019-06-26T21:56:33Z2019-06-26T21:56:33ZHow do I find amplitude of a signal within one second interval?Ive already plotted the graphs and even found the amplitude. But now, I would like to calculate the amplitude within a window of one second. Please help me. Below is my code:
%% Analysis of EMG data
%An EMG signal has a frequency between 0 to 500 Hz; but the usable
%frequency is between 50 and 150 Hz.
% EMG signal is produced using an instrument called the electromyograph that records electric activity
% produced by muscles.
% The amplitude for surface EMG signals is within the range of 0 to 10 mV.
% sEMG (surace EMG) signals tend to have a DC bias, therefore a high pass
% filter is applied to a cutoff frequency of 50Hz. This high pass filter
% removes any DC bias.
% The root mean-square (RMS): calculated by finding the square root of: squaring each data point,
%summing the squares, dividing the sum by the number of observations.
%RMS value of a signal is a measure of the power of the signal and it
%reflects on the activity in the motor unit during contraction.
% This makes RMS useful in producing waveforms.
% Amplitude of an EMG signal is random with Gaussian Distribution/
% RMS and MA are two parameters used to measure the amplitude.
% MA short for: Mean Absolute value: is a mean of the absolute value of
% EMG signal
% MA is a measure of the area under the rectified EMG.
% In order to calculate MA remove all of the negative phases of the raw EMG
% This is known as: half-wave rectification.
% The MA and RMS provide an estimate of the amplitude of the raw EMG signal.
t = EMGSampleData(:,1);
y1 = EMGSampleData(:,2);
N = length(y1);% find the length of the data per second
ls = size(y1); %% size
f = 1/N;% find the sampling rate or frequency
%Note: sampling frequency should be at least twice the incoming signal.
fs = 3000;
T = 1/fs % period between each sample
t1 = (0 : N-1) *T;
t = (0:1:length(y1)-1)/fs; % sampling period
% nyquist frequency is half of the sampling rate of a signal. Also known as:
% folding frequency.
Nyquist = fs/2;
figure;
%
subplot (3,1,1), plot(t,y1,'b');
title ('EMG signal of single muscle 40 month old patient ');
xlabel ('time (sec)');
ylabel ('Amplitute (V)');
grid on;
Y= abs(fft(y1));
Y(1) = [];
power = abs(Y(1:N/2)).^2;
nyquist = 500;
freq = (1:N/2)/(N/2)*nyquist;
subplot(212), plot(freq,power), grid on
xlabel('Sample number (in Frequency)')
ylabel('Power spectrumen');
title({'Single-sided Power spectrum' ...
' (Frequency in shown on a log scale)'});
axis tight
%%% RMS of the signal
rms_y1 = sqrt(mean(y1.^2));
msgbox(strcat('RMS of EMG signal is = ',mat2str(rms_y1), ''));
rms_emg = rms (y1);
%%%%% MA of the signal
ma_y1 = abs(mean(y1));
msgbox(strcat('MA of EMG signal is = ',mat2str(ma_y1), ''));
%remove any DC offset of the signal
% use the detrend function.
% It subtracts the mean or a best-fit line from data.
y2 = detrend(y1); %% y2 is the singal after DC offset removed.
figure;
rec_y = abs(y2);
plot (rec_y);
xlabel('Sample number (in Frequency)')
ylabel('Rectified EMG signal');
title({'Rectified EMG signal' ...
' (Frequency shown on a log scale)'});
figure;
xdft = fft(y1);
xdft = xdft(1:N/2+1);
psdx = (1/(fs*N)) * abs(xdft).^2;
psdx(2:end-1) = 2*psdx(2:end-1);
freq = 0:fs/length(y1):fs/2;
plot(freq,10*log10(psdx))
grid on
title(' Power spectrum FFT')
xlabel('Frequency (Hz)')
ylabel('Power/Frequency (dB/Hz)')
%amplitude of the entire signal
amplitude = max(y2(:)) - min(y2(:))
%%% DFT to describe the signal in the frequency
NFFT = 2 ^ nextpow2(N);
% The reason I used this function above:
%The execution time for fft depends on the length of the transform.
% It is fastest for powers of two. It is almost as fast for lengths that
%have only small prime factors. It is typically several times slower for
%lengths that are prime or which have large prime factors.
Y = fft(y1, NFFT) / N;
f = (fs / 2 * linspace(0, 1, NFFT / 2+1))'; % Vector containing frequencies in Hz
amp = ( 2 * abs(Y(1: NFFT / 2+1))) % Vector containing corresponding amplitudes
figure;
plot (f, amp);
title ('plot single-sided amplitude spectrum of the EMG signal')
xlabel ('frequency (Hz)')
ylabel ('|y(f)|')
grid on;Amer Yaghihttps://es.mathworks.com/matlabcentral/profile/authors/10978548-amer-yaghitag:es.mathworks.com,2005:Question/4690712019-06-26T20:37:25Z2019-06-26T21:50:06ZQuestion about Resource Allocation in MATLABI use confidential data available through a secure server and have been repeatedly encountering the following issue related to the early termination of a Matlab program/M file:
"PBS: job killed: cpus 34.1 exceeded limit 30 (burst)"
If I were to increase the number of CPUs to 40 or even 50, the M file would run for a while (20 minutes or so), and the job would then be killed off with the same message displayed.
The issue is not caused by errors in the M file itself, as the same program runs to completion in about 3-4 hours on my own Mac laptop with only 2 CPUs (when the program is tested on fake/simulated data). The issue (as I perceive it) seems to be caused by insufficient/incorrect resource allocation. However, this justification seems rather surprising as I previously thought that MATLAB is supposed to ``know" the number of available cores. I would really appreciate any suggestions/thoughts on how to get the M file running to completion.
As an addition clarification, I have run into issues with MATLAB though the server before, but in that case, I just requested 3 or 4 CPUs (as opposed to just 1 CPU). Maybe this particular case is different because the program (which searches for all the local maximums of a specific function) is more "computationally intensive"? It certainly has multiple nested for loops. Sherry Wuhttps://es.mathworks.com/matlabcentral/profile/authors/13767686-sherry-wutag:es.mathworks.com,2005:Question/4690762019-06-26T21:10:51Z2019-06-26T21:39:53ZRe-download Matlab to my new computerPurchased and downloaded Matlab 2013 on my old computer. I need to upload to my new computer. Can I do this?
Thank you,
Noelnoel mantohttps://es.mathworks.com/matlabcentral/profile/authors/3772777-noel-mantotag:es.mathworks.com,2005:Question/4074652018-06-26T09:54:55Z2019-06-26T21:38:36ZBar plot with color mapI have a table with x rows and two columns: fold change and p-value.
I'd like to make a bar plot such that the length of the bars will be according to the fold change value, and the color of each according to it's p-value (therefore colormap should be presented as well)
I couldn't figure out how i can do such thing, so if it's indeed possible on Matlab i would appreciate your help. Thanks!Rotem Katzirhttps://es.mathworks.com/matlabcentral/profile/authors/5688779-rotem-katzirtag:es.mathworks.com,2005:Question/1471032014-08-11T00:59:48Z2019-06-26T21:37:54Zincrement two values in a single for loopI was just wondering if there was a way to increment two variables simultaneously in a single for loop?
for example i want to increment
i = 1:1:n-times
but at the same time
j=1:1:m-times
in a single for loop
Duncanhttps://es.mathworks.com/matlabcentral/profile/authors/5351214-duncantag:es.mathworks.com,2005:Question/4690802019-06-26T21:33:33Z2019-06-26T21:33:33ZTrying to manually set rgb values of cells equal to 0 on contourf figureI am attempting to manually set the rgb values on the displayed heat map/2D graph created by contourf, taking data from my input array (a 33477x13 array) to a dark blue if the cell value is equal to 0. How would I do this?
Here is the code:
function [SMPS_data]=Contourf(A)
i=1;
while i<3
start_date = {'5-June-19 0:00','26-May-19 0:01'};
t1 = datetime(2019,5,26,0,0,0);
t2 = datetime(2019,6,4,0,0,0);
dates=t1:minutes(10):t2;
duration_min = numel(dates)*10;
SMPS_timestep = [0:10:duration_min];
colormap(jet)
SMPS_data=[A];
x=zeros(1,length(SMPS_data));
for j=1:length(SMPS_data)
x(1,j) = j/6;
end
y = [11.5; 15.4; 20.5; 27.4; 36.5; 48.7; 64.9; 86.6; 115.5; 154; 205.4; 273.8; 365.2];
z_o=zeros(1,numel(x));
z_r= SMPS_data(1:end,2:end).';
z = [z_o;z_r];
[X,Y] = meshgrid(x,y);
v=logspace(-1,15,500);
[X,Y] = meshgrid(x, y);
figure
[C,h] = contourf(X,Y,griddata(x,y,z,X,Y,'natural'),v);
C(C==0)
set(gca,'yscale','log')
ylim([-1 250]);
str=sprintf('Time (h), t(0) = %s', start_date{2});
xlabel(str)
ylabel('Particle diameter (\mum)')
set(h,'LineStyle','none');
c =colorbar;
caxis([0 2500])
hl = ylabel(c, 'dN/dlogDp #/cm^{-3}');
set(hl, 'Rotation',90);
set(c,'FontSize',12,'LineWidth',1.5)
set(gca,'FontSize',12,'LineWidth',1.5)
set(gca,'TickDir','out')
set(gca,'XTickMode','auto')
%set(gca, 'XTick',[0 6 12 18 24 30 36 42 48 54])
set(gca, 'XTickLabel',{'5/26','5/27','5/28','5/29','5/30','5/31','6/1','6/2','6/3','6/4'})
set(gca, 'YTick',[10 30 50 100 150 200])
set(gca, 'YTickLabel',{'10','30','50','100','150','200'})
box off
i=i+1;
end
endChristianhttps://es.mathworks.com/matlabcentral/profile/authors/15725648-christiantag:es.mathworks.com,2005:Question/2844862016-05-16T19:03:57Z2019-06-26T21:29:45ZSplitapply, each data of group in a new figure/plotHi all,
I am using the function splitapply. However I have problems with plotting each group in another figure (or hide one or more groups).
Currently I am using (attachment with .mat-file):
hold on
splitapply(@(difference_mean,difference)plot(difference_mean,difference,'o'),difference_mean,difference,G);
It would be the best to create three seperate figures with each group another figure. Alternatively, create 3 times the same figure and delete the other data.
Can somebody provide me with de solution :)?
Greetings,
MartijnKFrenkiehttps://es.mathworks.com/matlabcentral/profile/authors/3755731-kfrenkietag:es.mathworks.com,2005:Question/3468312017-06-29T18:34:37Z2019-06-26T21:21:27ZHow can I change the resolution of kinect V2 in matlab?Kinect V2 color stream supported format is : 1920x1080. But kinect V2 depth stream format is : 512x424. Now when I start live steam for both sensors then they have different sizes because of different resolution. I cant resize them, because I need coordinates . so when I resize using Imresize(),the coordinates are not matched. I already read matlab documentation.They said hardware only supports this two format respectively.Now How can i do this in code so that both stream have the same resolution. I tried two days long but failed.
sufian ahmedhttps://es.mathworks.com/matlabcentral/profile/authors/10225144-sufian-ahmedtag:es.mathworks.com,2005:Question/4685002019-06-23T20:04:00Z2019-06-26T21:18:39ZPushButton repeat previously generated audio sample (with other pushbutton)I will need to use the script below for a listening test. is still not as I need it and the deadline is approaching so I decided to come here and find out if someone can help. (Thanks in advance!)
Information about the script: I am using GUI; among other tools that are not relevant for this specific problem I have included 2 pushbuttons which are causing me some problems. One pushbutton is supposed to play one audio sample (randomly) out of 3 existing audio samples. The other pushbutton is supposed to play the sample again if the listener needs it.
My problems are due to this:
1- Each sample needs to be played randomly but the user needs to be able to listen to it again if he wants. I would like to use the "REPEAT" button for that.
2- I am using a different GUI for each of the three audio samples that will be evaluated by the listener (probably the worst idea ever as the GUIs are exactly the same, but it's how I managed to make it work so far). Each GUI has a "NEXT" button to close the old GUI and open the next one.
When the user changes from the first GUI to the second, the previously evaluated sample, must not be included in the random operation as they can't evaluate the same audio sample twice during the test.
------> I am not being able to solve these two issues and the deadline is almost here. PLEASE I need some help.
Thank you very much!
This is the code I am using for the pushbutton PLAY at the moment:
a = audioread('guitar.wav');
b = audioread('cinematic.wav');
c = audioread('epicorchestra.wav');
numsounds = 3;
sounds = { a; b; c;}
orders=randperm(numsounds,3); % random order
%pick one of the positions in "orders"
location = randi(length(orders));
% extract wave data from line identified by "locations" in column one.
wavData = sounds{location, 1};
% sampling frequency (same for all audio files)
sf = 48000
% play audio sample with that wavdata and corresponding sampling
% frequency
soundsc(wavData, sf);
Ana Camposhttps://es.mathworks.com/matlabcentral/profile/authors/9760934-ana-campostag:es.mathworks.com,2005:Question/4690732019-06-26T20:53:45Z2019-06-26T21:15:18ZSave vector to class propertiesGreetings,
I am trying to build a class that would extract information from .csv files and save these information to the properties of the class. Attached is the example of the file.
Here are my code:
classdef post_processing
properties
data_folder = 'path\path'
filename
time
voltage
norm_voltage
record_length
state_level_high
state_level_low
end
methods
function extract_info(obj)
addpath(obj.data_folder);
filename = 'test.csv';
data = readmatrix(filename);
horizontal_offset = data(6,2); %seconds
sample_interval = data(2,2);%seconds
record_length = data(1,2); %points
time = data(:,4)-horizontal_offset; %seconds
voltage = data(:,5); %volt
norm_voltage = data(:,5)/max(data(:,5));%arb. units
obj.time = time;
obj.voltage = voltage;
obj.norm_voltage = norm_voltage;
obj.record_length = record_length;
end
end
end
I called my script:
test = post_processing;
extract_info(test);
test
give output
I do not know why my properties are not updated when I called my extract_info function.
Thanks for the help.novelphyhttps://es.mathworks.com/matlabcentral/profile/authors/12897852-novelphytag:es.mathworks.com,2005:Question/4690502019-06-26T18:49:46Z2019-06-26T21:10:35ZHow can I read a specific range of lines from a text file without using a for loop?I need to read data from text files (a lot of them), and they are formatted as follow:
.
.
.
internalField nonuniform List<scalar>
241920
(
0
0
0
0
0
.
.
.
0
0
0
)
;
.
.
.
The data I'm interested is the zero after the "(". The 241920 is the number of lines of data. The numbers are not necesarily 0 (if it matters, their values are constrained as ).
I want to get these numbers in an array. So far, I first read the line containing the number of data points (it is located in line 22 of the text file) to intialize the array, then I used textscan in a for loop to read the text file line by line starting from line 24. The problem is that this process is VERY slow, and I need to read hundreds of these files (the number of rows can vary, but is always specified in line 22)
Here is the for loop I'm using (I copied the textscan funtion from another post, I'm honestly not sure how it works)
for i=1:fieldSize
alpha(i) = str2double(string(textscan(fileID,'%s',1,'delimiter','\n', 'headerlines',(linenum+i-1)-1)));
fseek(fileID, 0, 'bof');
end
% Where fieldSize is the number found on line 22 as previously mentioned
% linenum is where the data starts (which is 24 for these text files). The -2 added to the linenum is just to match the code I got it from
% alpha is the array to where the data is being exported to
What I want to do then is to make this code very efficient, and to do that I believe I need to eliminate the for loop and use a function that can read a range of lines, not necesarily starting at the beginning of the text file.
EDIT:
I attached a sample text file. The first 22 lines are constant, just info file from the program that produced the text file.Dennis Bonillahttps://es.mathworks.com/matlabcentral/profile/authors/15725099-dennis-bonillatag:es.mathworks.com,2005:Question/4690692019-06-26T20:24:31Z2019-06-26T21:09:57ZGetting "Undefined variable "images" or class "images.roi.Rectangle".I have the Image processing toolbox installed and the script I am using has been verified on other computers. Any help would be appreciated.Brandyn Kinseyhttps://es.mathworks.com/matlabcentral/profile/authors/14470651-brandyn-kinseytag:es.mathworks.com,2005:Question/4675772019-06-17T23:28:44Z2019-06-26T21:09:43ZFind the intersection of a square pixel with a closed 2D curve Dear MatLab Experts,
I would appreciate your help with the following problem.
I have a set of closed concave 2D curves of arbitrary shape. The coordinates of the polygonal curve are known.
I cover the areas inclosed by the curves with square pixels whose side is a parameter. Therefore the pixels may be smaller or larger.
The rim of the area (curve) must be covered by the square pixels as well. Please, see the attached pictures.
Question:
How can I find the pixels that intesect the curve as distinguished from the pixels totally contained inside the curve?
Thank you in advance for any suggestion and help.
Kind regards,
Maura E. M.
Maura Monvillehttps://es.mathworks.com/matlabcentral/profile/authors/13231254-maura-monvilletag:es.mathworks.com,2005:Question/4690742019-06-26T21:07:28Z2019-06-26T21:07:28ZHow do I perform a frequency sweep on a .WAV file?Hello,
I found the following code online and am using it as a sort of template for performing a frequency sweep on a .WAV file in MatLab.
wave_file = 'name.wav';
[wave_data_time, sample_rate] = wavread('name.wav');
N_temp = length(wave_data);
N = 2^nextpow2(N_temp);
buff = floor((N-N_temp)/2)+1;
Nyq = sample_rate/2;
df = sample_rate/N;
f = -Nyq:df:Nyq-df;
wave_data_time_pad = zeros(size(f));
wave_data_time_pad(buff:buff-1+N_temp) = wave_data_time;
wave_data_freq = fftshift(fft(wave_data_time_pad));
figure;
plot(f,real(wave_data_freq),'b-',f,imag(wave_data_freq),'r-');
However, after compiling, I am recieving this error:
Undefined function or variable 'wavread'.
Error in freq_sweep_ECE223 (line 2)
[wave_data_time, sample_rate] = wavread('name.wav');
Is there an alternative function or approach that newer versions of MatLab supports? Also, is there an easier way to perform a frequency sweep on an input audio file using the spectrogram function in MatLab?
Many thanks!regan garnerhttps://es.mathworks.com/matlabcentral/profile/authors/15228364-regan-garnertag:es.mathworks.com,2005:Question/2617212015-12-27T15:11:02Z2019-06-26T21:05:42Zhow to make Geometric shapes detection?i have popup menu to detect shapes. for example, i need when i click circle, just circles will show in rgb image on axes2. i am new to this, so couldn't arrange anything. Can anyone help me? i upload my codes. i think, you can understand exactly what i mean, when you check color menu on my codes. thank you.mete polathttps://es.mathworks.com/matlabcentral/profile/authors/6222869-mete-polattag:es.mathworks.com,2005:Question/1850262015-03-24T21:39:32Z2019-06-26T21:03:08ZPCA scaling and centering documentation wrong?The pca() documentation says that the raw data is automatically centered at the start of the process. If true, then pca(X) should be equal to pca(Y), where Y = centered data. But they're not (specific data below). Additionally, when I use either eig() or svd() to compute the principal components, I can only get them to match the pca output when I first manually center the data before using pca().
Ultimately my question is simply how do I correctly calculate the principal components of raw data? I.e. do I need to manually center and scale it first? Only manually center? Only manually scale?
Sample data: X =
1.0000 -3.0000 -1.0000;
2.0000 -2.0000 -0.5000;
3.0000 -0.5000 0.2500;
4.0000 2.0000 1.0000;
5.0000 5.0000 2.5000;
Centering X ->
Y=
-2.0000 -3.3000 -1.4500;
-1.0000 -2.3000 -0.9500;
0 -0.8000 -0.2000;
1.0000 1.7000 0.5500;
2.0000 4.7000 2.0500;
pca(X) =
-0.7360 -0.6037 -0.3062;
-0.6688 0.7186 0.1907;
-0.1049 -0.3452 0.9327;
pca(Y) =
0.4058 0.8414 0.3569
0.9124 -0.3960 -0.1036
0.0542 0.3676 -0.9284
svd(Y) = 0.4058 0.9124 0.0542;
0.8414 -0.3960 0.3676;
0.3569 -0.1036 -0.9284;
eig(cov(Y)) = 0.0542 0.9124 0.4058;
0.3676 -0.3960 0.8414;
-0.9284 -0.1036 0.3569;
^this is the same output just in a different order.Ari Paulhttps://es.mathworks.com/matlabcentral/profile/authors/4881839-ari-paultag:es.mathworks.com,2005:Question/4686682019-06-24T18:01:45Z2019-06-26T21:02:17ZMarking rectangles on images automaticallyHi,
I am trying to write a code that would allow me to detect rectangles with a certain area automatically in an image.
For example, the code should allow me to detect the reactangle like the one shown in the image attached rather than manually drawing it using roipoly() or a function of the same kind. The area is such that there is no break or black area in the image.
Kindly let me know if there is more details if required
Thank youYash Mayuresh Kavihttps://es.mathworks.com/matlabcentral/profile/authors/9505165-yash-mayuresh-kavitag:es.mathworks.com,2005:Question/4688792019-06-25T20:11:17Z2019-06-26T20:59:19ZExact same code producing different color scheme MATLAB plotHello
When a colleague below runs the code attached, they claim to get a figure 4 with a color scheme that look likes attached image 1. When I run the exact same conde on MATLAB online, I get firgure 4 that looks like attached image 2. I cannot figure why this is and need my code's figure 4 output too look like that in image 1.Palash Agrawalhttps://es.mathworks.com/matlabcentral/profile/authors/14613896-palash-agrawaltag:es.mathworks.com,2005:Question/4688762019-06-25T19:53:00Z2019-06-26T20:58:39ZWhy does the right-click context menu appear at the bottom of my figure? (R2018b, Update 2)Hello,
In my app, I am using drawrectangle() to allow the user to interactively create a rectangle in an axes in a figure. After the rectangle is created, the user can right-click the rectangle to bring up a context menu. However, the menu appears as a little appendage down at the bottom of the figure, not at the location of the right-click.
In searching MATLAB Answers, I see that this question was asked before (with some specifics about figure zoom being enabled, which I don't think applies to my case). The Mathworks Support Team answer to this question says that this is a bug that was fixed in R14SP2.
https://www.mathworks.com/matlabcentral/answers/99505-why-does-the-right-click-context-menu-appear-at-the-bottom-of-my-figure-instead-of-at-the-mouse-poin
But it appears that I am either seeing a related, but different, bug. Or I am seeing the same bug that has not been completely fixed. Can someone help?
Thank you,
MichelleMichellehttps://es.mathworks.com/matlabcentral/profile/authors/2122787-michelletag:es.mathworks.com,2005:Question/4690722019-06-26T20:39:41Z2019-06-26T20:58:34ZHow to fill up a huge/very large matrix, with elements from another matrix in a time efficient way? Hi there,
I am doing some calculations for some graph/network with vertices that have certain connections/edges to each other.
My goal is to set-up a very large matrices with dimensions ranging from roughly 90000x300(works but already takes up ~4.6 seconds to create) up to 9,000,000 (9mln)x30000 elements in an efficient way, such that is does not take forever to fill up the matrix. Most elements are, however, zeros so I tried using sparse matrices, but sparse matrices are not suitable if you want to fill them up element-wise.
The size of the matrices depend on a discretization parameter(delta) that I choose, I need to make it as small as possible, down to 10^-4. My function is now as follows(I use Hungarian notation):
function mZ_j = createZ_j(iN, iP, iD_j, mX, vPA)
% Function that creates design matrix Z_j.
% Dimensions: (n-p)x(p*d_j)+1, d_j can go up to 6, but is 2 on average
% input/starting parametes are:
% delta = 0.0001, s=0.5, T=900(15 min in seconds), d_j=2
iRows = iN-iP; % n:= T/delta, p:=s/delta
iCol = (iP*iD_j);
mZ_j = zeros(iRows,iCol); % (n-p)x(p*d_j) matrix
mX_j = mX(:,vPA); % matrix were elements will be taken from, vPA(size iD_j) has the column indexes
p = iP+1; % indicator for each row; it is an autoregressive process and each row you regress on p lags, but every row you take one next step in time
for i=1:iRows
for j=1:iP
iCStart = ((j-1)*iD_j)+1; iCEnd = j*iD_j;
mZ_j(i,iCStart:iCEnd) = mX_j(p-j,:);
end
p = p+1;
end
Does anyone see or know how I can assign the elements from mX_j more efficiently to mZ_j? The operations themselve do not take a lot time, it is just the amount of iterations that it has to do.
Thanks!Jeroenhttps://es.mathworks.com/matlabcentral/profile/authors/13531204-jeroentag:es.mathworks.com,2005:Question/4690662019-06-26T20:05:19Z2019-06-26T20:55:34ZI'm having trouble plotting imported xy or xyz dataI imported x,y, and z values from a .csv file using the "Import Data" button. I then used the following to get X, Y, and Z data to plot. I tried doing a 2D plot as well and a 3D surface and keep getting "Error using tabular / plot Too many input arguments". What am I doing wrong? Ultimately I want to do a 3D surface plot of the X Y and Z data points. Help :)
XData=XYZData(:,1);
YData=XYZData(:,2);
ZData=XYZData(:,3);
ZData
XYZData
plot(XData, ZData)
%surf(XData, YData, ZData)
%plot(XData)
%plot(XYZData)Tony Hollowayhttps://es.mathworks.com/matlabcentral/profile/authors/12227858-tony-hollowaytag:es.mathworks.com,2005:Question/4531072019-03-28T16:38:10Z2019-06-26T20:55:27Zhow can i solve this ,can anyone provide me with code? whats wrong with my code ?Write a function called valid_date that takes three positive integer scalar inputs year, month, day. If these three represent a valid date, return a logical true, otherwise false. The name of the output argument is valid. If any of the inputs is not a positive integer scalar, return false as well. Note that every year that is exactly divisible by 4 is a leap year, except for years that are exactly divisible by 100. However, years that are exactly divisible by 400 are also leap years. For example, the year 1900 was not leap year, but the year 2000 was. Note that your solution must not contain any of the date related built-in MATLAB functions.
function [valid]=valid_date(year, month, day)
if isscalar(year) && year>0 && year~=0 && isscalar(month) && month>0 && month~=0 && isscalar(day) && day>0 && ar
if mod(year,4) == 0 && mod(year, 100)~= 0 || mod(year,400)==0 && month==2 && days<=29
%for february
valid=true;
else
valid=false;
end
%for rest of the months
if month==4 || month==6 || month==9 || month==11 && day<=30
valid=true;
elseif month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month== 12 && day<=31
valid=true;
else
valid=false;
end
%not a leap year
if month==2 && day>28
valid=false;
end
%rest of the months
if month==4 || month==6 || month==9 || month==11 && day<=30
valid=true;
elseif month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month== 12 && day<=31
valid=true;
else
valid=false;
end
else
valid=false;
end asad jaffarhttps://es.mathworks.com/matlabcentral/profile/authors/14997254-asad-jaffartag:es.mathworks.com,2005:Question/4690462019-06-26T17:52:01Z2019-06-26T20:50:55ZFourier Transform by using MATLABHello,
I want to use fft to get the frequency information of the signal in time domain. However, I find the frequency of the signal is determined by the sampling frequency. For example, if the sampling frequency is 1000 Hz, the signal frequency is in 100Hz, but when it changes to 2000Hz, it will be in 200Hz. Does anyone know how to solve this problem? The code is shown as following.
Thank you for your help.di liuhttps://es.mathworks.com/matlabcentral/profile/authors/11122097-di-liutag:es.mathworks.com,2005:Question/4190362018-09-13T04:00:00Z2019-06-26T20:39:44ZWhat happened to the figure toolbar in R2018b? Why is it an axes toolbar? How can I put the buttons back?In R2018b, tools such as the zoom, pan, datatip, etc are no longer at the toolbar at the top of the figure window. These buttons are now in an "axes" toolbar and only appear when you hover your mouse over the plot. How do I put the buttons back at the top of the figure window?
<<http://www.mathworks.com/matlabcentral/answers/uploaded_files/142593/b53c2d62f5bb995fe63fe61cf81eaf86.png>>
MathWorks Support Teamhttps://es.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:es.mathworks.com,2005:Question/4690702019-06-26T20:25:10Z2019-06-26T20:38:11ZHow to add more than one structure to a .mat fileI am trying to make a GUI that lets you read a name, chemical equation, and enthalpy and then puts that into a structure. Then save the structure to a file called propellant.mat. The name of the stucture is a user input (which is bad practice, but in this case it will work).
This is what I have, but it doesn't do what I want:
prop_name = get(handles.edit2, 'String');
data = get(handles.uitable1, 'data')
new_form = data(1,1);
new_h = data(1,2);
prop.(prop_name).name = prop_name;
prop.(prop_name).form = new_form;
prop.(prop_name).h = new_h;
save('propellant_lib.mat', 'prop', '-append');
What I what to happen is when you load propellant.mat there are many different propellant structures (prop_a, prop_b, pro_c, etc.) that have been saved by the user so at anytime propellant.mat can be loaded in and the contents of the propellant data base can be used.
Any recommended ideas on how to do this better is also appreciatedBrad Bullerhttps://es.mathworks.com/matlabcentral/profile/authors/8779735-brad-bullertag:es.mathworks.com,2005:Question/3522902017-08-10T13:23:38Z2019-06-26T20:37:20ZSet Colorbar TickLabels and TickMarksHi all,
I am having trouble setting my colorbar ticklabels as I wish.
Specifically I have 8 points, and have created a colormap such that these 8 points get values from the darkest to the lightest color in the colormap. Similarly, I would like my colorbar's labels to follow the same pattern. Below is the code that I have written:
cmapdef = colormap(winter) ; %Define Colormap
cmap = cmapdef(1:8:end, :) ; %Find Values of colors corresponding to each point plotted
cbh = colorbar('YTickLabel', num2cell(1:8)) ;
However, the resulting colorbar has labels going as follows: 1 2 3 4 5 6 7 8 1 2 3. Instead I would expect the whole span of the color bar to be covered by 1 2 3 4 5 6 7 8.
What am I doing wrong?
Thanks in advance for your responses,
KMT. Konstantinos Tsitsilonishttps://es.mathworks.com/matlabcentral/profile/authors/9650432-konstantinos-tsitsilonistag:es.mathworks.com,2005:Question/4688872019-06-25T22:23:21Z2019-06-26T20:35:26ZHeat transfer question in pde toolboxHello all,
I have a question about using pde toolbox for heat transfer analysis. I used
createpde('thermal','transient')
to create the heat transfer model for analysis. And it seems that MATLAB solves heat transfer equations where only thermal conductivity is temperature-dependent as shown in the examples, and the equation is in the form
But I defined all of density, specific heat and thermal conductivity as temperature dependent. Will MATLAB provide a correct solution?
Any explanation or reference will be highly appreciated. Thank you very much!
Best,
Shengyue
Shengyue Shanhttps://es.mathworks.com/matlabcentral/profile/authors/11913548-shengyue-shantag:es.mathworks.com,2005:Question/4690572019-06-26T19:35:41Z2019-06-26T20:35:12ZHow to plot a 3d graph with z axis, not the same length as x,yI have a matrix of values where the first column is the x data (229 rows), then the next 52 columns (also 229 rows) are the corresponding y data at different times. I am trying to plot a 3d graph where the z direction is the y data at one of the times vs the x data. Does anyone know how to do this as mesh and surf require matrixes and stem3 requires all the vectors be the same length, where currently xdata (229x1), ydata(229x1) and zdata(52x1).Elena Corbaehttps://es.mathworks.com/matlabcentral/profile/authors/8672194-elena-corbaetag:es.mathworks.com,2005:Question/4690472019-06-26T18:12:40Z2019-06-26T20:35:11ZHow do I find rows with certain nested strings? I have a list of students:
Students=['Kerry';'Janet';'Cam';'Tyler']
their birthdays:
Birthdays=['June 1';'July 8';'December 2';'February 7']
and then a nested cell with their pets:
Pets={{'Cat','Fish'};{'Cat','Dog'};{'Bird','Fish'};{'Dog','Hamster'}}
I would like to find the indices of rows that corresponds to the students who have a Cat and or Bird, and eliminate the rows in all the arrays so I get the following information:
idXCatBird= %HELP IS NEEDED HERE
% Answer should be idXCatBird=[1;2;3];
Students=Students(idXCatBird);
Birthdays=Birthdays(idXCatBird);
Pets=Pets(idXCatBird);
I could do:
listCat = cellfun(@(listCat)strcmp(listCat,'Cat'),Pets,'UniformOutput',false);li
listCat=cellfun(@any,listCat)
listBird = cellfun(@(listBird)strcmp(listBird,'Bird'),Pets,'UniformOutput',false);li
listBird=cellfun(@any,listBird)
numCatBird=listCat+listBird;
[idxCatBird,~]=find(numCatBird)
But I was hoping there was a faster way! Kris Govertsenhttps://es.mathworks.com/matlabcentral/profile/authors/13755200-kris-govertsentag:es.mathworks.com,2005:Question/4681592019-06-20T21:38:54Z2019-06-26T20:27:15Ztext scan question of amplitude and phaseHello i have a string which is as follows:
(-7.30313259052058e-002dB,-4.26354774426478e+000°)
how can i extract these two numbers -7.30313259052058e-002 and -4.26354774426478e+000 exactly ?
I would like to get an array 1X2 where the first number is -7.30313259052058e-002 and the second is -4.26354774426478e+000.
I tried text scan %f in many forms its not working.
Thanks
fima vhttps://es.mathworks.com/matlabcentral/profile/authors/8659326-fima-vtag:es.mathworks.com,2005:Question/4690642019-06-26T20:04:52Z2019-06-26T20:22:38ZMy program does not display the values of v and w; might be a problem with the nester function. How can I modify the program in order to display v and w?
function []= numerical_differenctiation1D()
clear all
data=load("T215_4_000_1.mat");
nestedfun1
nestedfun2
function [dfdx]=nestedfun1(xi,xi1,yi,yi1)
xi1 = data.Location_of_measured_points(1,6);
xi = data.Location_of_measured_points(1,5);
v = (xi1-xi);
disp(v)
end
function [dfdx]=nestedfun2(xi,xi1,yi,yi1)
xi1 = data.Location_of_measured_points(1,4);
xi = data.Location_of_measured_points(1,5);
w=(xi-xi1);
disp(w)
end
end
Maher Abdou Alyhttps://es.mathworks.com/matlabcentral/profile/authors/15657446-maher-abdou-alytag:es.mathworks.com,2005:Question/4690682019-06-26T20:22:01Z2019-06-26T20:22:01Zpdepe solver boundary condition setup for discrete measured heat flux data Consider 1D trainsient heat transfer into a slab(steel,0.3m thick) with uniform initial temperature T0, where the lower boundary is insulated and the upper boundary surface have a uniform along the surface but discrete in time heat flux term q(t)----supose q(t) includs the measured data point with sampling frequency 10Hz...How to set up the PDEPE solver to compute the temperature histry of a node inside the slab (x=0.15m）...
Thanks for all the help.Chunlei Wanghttps://es.mathworks.com/matlabcentral/profile/authors/14234270-chunlei-wangtag:es.mathworks.com,2005:Question/1015562013-03-13T15:39:00Z2019-06-26T20:19:30ZIs it possible to define a variable as static within a MATLAB MATLAB file?I would like my variable values to have persistent storage from one call of my MATLAB file to another or within subfunctions. I wish to know if there is an equivalent in MATLAB code to static variables in C subroutines.
MathWorks Support Teamhttps://es.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:es.mathworks.com,2005:Question/4690672019-06-26T20:14:00Z2019-06-26T20:14:00ZManipulating Data in a textfile and Rewriting to a new fileI am struggling to write a program that will manipulate a text file. I am looking to manipulate columns 8 and 9 of the text file by finding the first order differences, increasing/decreasing the differences by a percentage (I used 20% in my code), and write a new textfile containing the new columns 8 and 9 and leaving all other columns the same.
I have this code, given help by another member.
function [D,StepInfo] = ImportSpecialTextFile(filename)
fidi = fopen(filename,'rt');
k1 = 1;
while ~feof(fidi)
for k2 = 1:3
StepInfo{k1,k2} = fgetl(fidi); % ‘Step Information’ Section Header Lines Cell Array
end
C = textscan(fidi, ['R' repmat('%d',1,10)], 'Delimiter',',', 'CollectOutput',true);
M = cell2mat(C);
if isempty(M) % Empty Matrix Indicates End-Of-File In Case Of Missing ‘End-Of-File’ Indicator
break
end
D{k1,:} = M;
fseek(fidi, 0, 0);
k1 = k1 + 1;
end
fclose(fidi);
end
With a call to the function:
filename = 'extractcdb.txt';
[D,StepInfo] = ImportSpecialTextFile(filename)
However, previously i used this code:
syms X Y z
fid = fopen('extractcdb.txt','r');
count =0;
chr= ('I''V''D''R');
tf= ischar(chr);
for chr = ('I''V''D')
tline = fgets(fid);
continue
end
for chr= ('R')
tline = fgets(fid);
A = textscan(fid, '%*s %*s %*s %*f %*f %*d %*f %*d %*d %d %*d','Delimiter',',');
Ad = cell2mat(A);
B = [diff(Ad)]*1.2;
B =[zeros(length(Ad) - length(B),1);B];
for i = 1
z = 1:708
C = cumsum(B(i+z)) + Ad(i)
end
end
which allowed me to find the first order difference of clumns 8 and 9 one at a time (I am doing column 9 in this code) and increased it by 20% and added it back to the column 9. However, this code did not allow me to go through all the data at once. I want the program to ignore the I,V,D lines and read all of the R lines and manipulate columns 8 and 9 and then start over at the next set of R values and increase those by the same percentage. After manipulation, I am trying to figure out how to get it to write a new text file containing the previous data with the new columns 8 and 9. Any suggestions would be greatly appreciated.Bradley Sprinklehttps://es.mathworks.com/matlabcentral/profile/authors/14123129-bradley-sprinkletag:es.mathworks.com,2005:Question/4690532019-06-26T19:14:29Z2019-06-26T20:12:18ZAdd new variable to table based on conditionHi,
I apologize for the newbie question but how does one add a variable to a table in Matlab based on conditions applied to other variables ?
For example, in the code below if t.y < 4 & t.y > 2 then 'A' should be stored in a new collumn t.z. Which doesnt work. Any ideas ?
y = [1 2 3 4];
x = [5 6 7 8];
t = table(x', y', 'VariableNames', {'x', 'y'})
if t.y < 4 & t.y > 2
t.z = 'A'
end
Bluehttps://es.mathworks.com/matlabcentral/profile/authors/15217011-bluetag:es.mathworks.com,2005:Question/4615732019-05-12T06:25:55Z2019-06-26T20:09:59ZOverwriting a diary fileI want to save my output to .txt file. I have used
diary Output.txt
diary on
some code
diary off
It saves diary file in same directory. But when I run the same code again it writes the command window output under the previously saved content instead of overwriting. I want to overwrite the previous content and make a file having only single output.Karanvir singh Sohalhttps://es.mathworks.com/matlabcentral/profile/authors/15432750-karanvir-singh-sohaltag:es.mathworks.com,2005:Question/4688942019-06-26T00:20:16Z2019-06-26T20:08:38ZResizing Callbacks with invisible figuresI'm running into an issue where I've attached the following to a figure:
figHandle.SizeChangedFcn = @(src,event) set(src.Children(3),'Position',get(src.Children(end),'Position'));
The goal of this is to move a specific element (in this case, a legend), in line with a second element (another legend for the primary axes). If relevant, the idea is to move the legend of an invisible axes in line with the legend already associated with the visible one. I have two questions:
The invisible axes don't scale like the other axes. The first is one with many lines plotted on it, while the second is a bar plot, drawn with the intention of creating a color code for an img plotted on the same space. the reason for this legend related callback is because for whatever reason, I can't make the axes scale identically. Is there some content I can load into the invisible axes that will solve this?
In the event I can't get the two axes to scale identically, I need to make this callback work slighty differently. At the moment, making the function invisible leads to the callback being disabled for some reason - is there another callback which I may be able to take advantage of, which is triggered in the event of a resizing (or which I can enable to be so) which is not influenced by figure visibility.
Any help would be appreciatedaboharbfhttps://es.mathworks.com/matlabcentral/profile/authors/9244971-aboharbftag:es.mathworks.com,2005:Question/4391262019-01-10T11:01:16Z2019-06-26T20:06:01ZHow to resize the input of a preprocessing layer of ResNet?
I've been trying to resize the Preprocessing to 224x224x1.
Input layer can be adjust easily but this one is always telling me the function 'Predict' is not correctly used.
and also I cannot directly change the size as I did to the input layer, I don't see why there's no property like it has in it's layer above.
I'm not sure if it's even could be could a layer...
Question from a begginner.I'm sorry if I bothered in this community.
Alexander Navihttps://es.mathworks.com/matlabcentral/profile/authors/14101458-alexander-navitag:es.mathworks.com,2005:Question/4690632019-06-26T20:00:16Z2019-06-26T20:05:57ZI want to plot z such that z(:,1)= [0;1]; but how do I implement that in this codeclose all;
dt = 0.1;%time step
u1=1;
u2=2;
c = u2-u1;
u = sign(u2-u1);
z=u*c;
k=0.12;
m=2.21;%initial parameters
v=1;
a=1.4;
tend=1000;
t=0;
i=1
while (t < tend-2*dt & i<t)
vh=v(i)-dt*k*z(1,i)/ (2*m);
z(2,i) = z(1,i)+ dt*vh;
%a(i+1)= -k*z(i)/2;
v(i+1)= vh-dt*k*z(2,i)/ (2*m);% + dt*a(i+1)/2;
i = i+1;
t = t + dt
end
plot(z);
Advait Sinhahttps://es.mathworks.com/matlabcentral/profile/authors/8795068-advait-sinha