Find specic quantities within a vector or within a matrix in Matlab
I need to identify the time at which the following values occur, namely: eta = 0 and eta = 0:51;
I should work with 'find' code, but could not get desired value. I know how it works in 'maximum':
t = -10:1:10; t = t'; eta = -t .^2; ind = find (eta == max(eta)); t_etamax = t(ind ,1); t_etamax = t(ind ,1); eta_max = eta (ind ,1);
Now I need not Maximum but when eta=0 and eta=0.51
See also questions close to this topic
Extracting all minimum values from a data-set into a matrix
I'm trying to write a program which extracts the minimum temperatures from a data-set,
data, for a given month, time and year.
Meaning that a person should be able to select a time, start-/endyear and get a matrix,
lowTempsOverYears, which should contain all the lowest-recored temperatures for january-december between two selected years at certain time.
Demonstrating what I mean I'll give a brief example. Take the two years: 1997-2001 and a time say 1200. This should give me a matrix containg the lowest tempartures recored for all months between the years 1997 and 2001. The output should be a 4x12 matrix where I have 4 different temperatures for every column which denotes the month.
You can find my program below:
function algo= getMiniserie(data, startYear, endYear, time) YearInterval = startYear:1:endYear; for month = 1:12 lowTempsOverYears = zeros(length(YearInterval),12); for yearNumber = 1:length(YearInterval) year = YearInterval(yearNumber); p = extractperiod(data,year,month,time); if ~isempty(p) q = min(p); lowTempsOverYears(yearNumber,month) = q; end end algo = lowTempsOverYears; end end
datavariable, from which I extract my data, consists of 3 columns and 400k+ so rows.
*first column denotes the date(YYYYMMDD)
*second column denotes the time
*third column denotes the temperature
And what the
extractperiodfunction does is that it, as the name would suggest, extracts all temperatures for a given month/year/time.
When I try to call my function by:
>> getMiniserie(data, 1997, 2001, 1200)
I only get jibberish. So I don't think it would be able to bring some new insight.
Any ideas to how I could improve my code to get my desired output?
My idea was that to make a variable which stores all the minimum values for each iteration of month.
So I initilized
lowTempsOverYearsto make it a(in this particular case wherethe start-/endyear is 1997 and 2001)
4x12matrix. Where during the first month-iteration it stores all the minimum temperatures for january in the first column , where all the selected years are represented by the rows.
Please feel free to ask if I've omitted something from my explanation, I'll happily add to the picture.
Comparing Multiple File Types in an if Statement
I am importing a file into a function using
[filepath, name, ext]=fileparts(thisFile);. I would then like to use a series of if statements that will operate on the file depending on its type; however, come files will have the same initial set up and so I would like to be able to include them all in an if statement. My current implementation:
elseif (ext == '.s3p'). If I put in something like:
elseif (ext == '.s2p' || '.s3p')the compiler whines,
Operands to the || and && operators must be convertible to logical scalar values.
You see my logic. Is there anything that I can do to make this work?
Thank you in advance!
three phase diagram plot in matlab?
I am trying to generate a three phase saturation plot in Matlab.
I found this code in matlab and it does generate something similar but not exactly the same
As much it looks simple, I dont know how to adjust the values to match the plot in the figure. As I dont have a specific values. Even if there is a way to generate the shading of the colors that changes from one edge to another that would be fine Any suggestions please
% Main file for ternary plot close all; clear all; clc; A = [... 1.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 1.000 0.330 0.330 0.340 0.340 0.000 0.660 0.000 0.340 0.660 0.000 0.160 0.840 0.160 0.000 0.840 0.000 0.153 0.847 ]; l=length(A); % A(l+1,:)=[1 0 0 6]; % A(l+2,:)=[0 1 0 30]; % A(l+3,:)=[0 0 1 1]; % ... and the GPR velocity % v=0.29./sqrt(A(:,4)); data = [... 0.0 0.0 0.0 0.419 0.273 0.090 0.014 0.010 0.00 ]; v = data; figure; % Plot the data % First set the colormap (can't be done afterwards) colormap(jet) [hg,htick,hcb]=tersurf(A(:,1),A(:,2),A(:,3),v); % Add the labels hlabels=terlabel('Gas','Water','Oil'); set(hg(:,3),'color','m') set(hg(:,2),'color','c') set(hg(:,1),'color','y') %-- Modify the labels set(hlabels,'fontsize',12) set(hlabels(3),'color','m') set(hlabels(2),'color','c') set(hlabels(1),'color','y') %-- Modify the tick labels set(htick(:,1),'color','y','linewidth',3) set(htick(:,2),'color','c','linewidth',3) set(htick(:,3),'color','m','linewidth',3) %-- Change the colorbar set(hcb,'xcolor','w','ycolor','w') %-- Modify the figure color set(gcf,'color',[0 0 0.3]) %-- Change some defaults set(gcf,'paperpositionmode','auto','inverthardcopy','off')
List all files that are executable and start or end with a digit
So the full question is here:
Write to stdout the list of all files below the directory
/etcthat are executable for all other users and whose name starts or ends with a digit.
I have been trying stuff like this:
find /etc -type f -executable -name "*[0-9]" -name "[0-9]*"
find /etc -type f -perm /u=x,g=x,o=x \( -name "*[0-9]" -o -name "[0-9]*" \)
But when i turn this in it says it's wrong, I get a few errors like "permission denied" but i don't know if this is what causes it to be wrong. Anyone see what i could be doing wrong? and yes im new to linux.
Problem with update and search in Adobe Acrobat Reader on Linux
I recently installed Adobe Acrobat 2019.008.20071 by using wine on Manjaro KDE Plasma. I have these two problems:
1) Find function is not working, it seems as if it was searching but it does nothing, and I cannot close the box below. View my picture
Maximum Cache Size always shows nothing in Preferences.
2) Sometimes when opening/closing Adobe Acrobat Reader appears a window for updating and it stays forever without doing nothing. How can I disable this operation?
Thanks in advance.
PS: I don't have "wine_gecko" and "wine-mono" installed
How can i find ip address' geolocation?
I'm trying to find a person that won't to meet me in rl. This person have to bring me back some money and call me with private number or turn off your phone. Only thing i have is an email exchange. Thanks in advance.