Array from MAtlab
Hi Everyone,
I scripted some code in Matlab and used it with LABVIEW using the M-script support. But, I want to perform the same task using labview.
The code has been attached. Please help me out with the array part. I can't figure out how to modify the elements of the array. Easily and hence use it for switching diodes on and off as it switches between "1" and "0".
thank u!!
Solved!
Go to Solution.
Attachments:
matlab code.txt 1 KB
I want to maintain the value of a variable at a certain arbitrary value that can be modified. (which i am setting using knob control).
If the value falls below the required value, Diodes light up in proportion to the difference in the values vice vera if the value exceeds the required level.
Every diode is assesed as an additional 50 input to the value of variable.
I am also attaching a snap of the VI, I prepared. Please have a look.
I hope the problem is now clear to you.
Attachments:
Proj-1.jpg 50 KB
Similar Messages
-
Passing arrays from matlab to vi-controls by activex
Dear specialists,
I am trying to set an array of doubles that is defined as a control in my VI by using:
invoke(VIhandle, 'SetControlValue', mlarray)
where mlarray is defined in Matlab as an 1xn array of doubles.
error: ??? Dispatch : Exception occurred
in routine: actxcli
Reading an indicator array in the VI by 'GetcontrolValue' works fine.
Also passing non-array variables works fine.
How should I define my array in Matlab/Labview to make it work ?I do not have a copy of Matlab but I can help you search the web. Is your error from windows, matlab, or labview? I could find nothing on NI's site for actxcli. Is this the exact error message?
-
How to populate multi-cluster arrays using matlab code?
Hi,
I have an array of clusters containing two 'Double' elements in each cluster. I am looking for a method to populate this array using MATLAB code. I need around 1000 clusters in the array, so populating it using the front panel is not practical. There is also some calculation involved in deciding the value in each element. If there is an example or a method to do this, please point me in the right direction.
Thanksaltenbach wrote:
Can you attach a typical file so we know that the structure is? It is easy to convert from any data structure to any other data structure. You could even read it as a 1D string array and parse each line into a cluster, for example. It all depends on how the fil is arranged. You could also read the file as a flat string and chop it up into the desired structure later.
I have attached the .vi file. I need to convert the spreadsheet to an array of clusters, thats where I'm getting stuck. (The vi is an example from help libraries)
That is the part where I need to change so that I can use a spreadsheet.
Attachments:
Buffered counter.vi 52 KB -
Adding data to array from an empty query
I am trying to add data to an array from a database query, however some queries will return no data (empty set). In that case I would like to add fake data so that the index size matches my other array (assetsid).
Thank you for your time.
int f2a=0;
String[] exportedtime;
String[] exportedtime_formated;
ArrayList exportedtime_ar = new ArrayList(f2a);
ArrayList exportedtime_formated_ar = new ArrayList(f2a);
for (int jj=0; jj<assetsid_ar.size(); jj++)
String eng_id_out = (String) eng_id_h2a_ar.get(jj);
String fuel2a = "select engineserialnumber, TO_CHAR(exportedtime, 'MM/DD/YYYY HH24:MI:SS') exportedtime, TO_CHAR(exportedtime, 'DD/MON/YY') as exportedtime_formated from tblexportedjobs where exportid = (select max(exportid) from tblexportedjobs where engineserialnumber = "+eng_id_out+") and engineserialnumber = "+eng_id_out+"";
ResultSet fuel2a_myResultSet = stmt.executeQuery(fuel2a);
while (fuel2a_myResultSet.next()) {
f2a=f2a+1;
exportedtime = new String[f2a+1];
exportedtime_formated = new String[f2a+1];
exportedtime[f2a]=fuel2a_myResultSet.getString("exportedtime");
exportedtime_formated[f2a]=fuel2a_myResultSet.getString("exportedtime_formated");
if (exportedtime[f2a].equals("")) {
exportedtime[f2a] = "01/01/2004 00:01:01";
} else {
exportedtime[f2a] = exportedtime[f2a];
exportedtime_ar.add(exportedtime[f2a]);
if (exportedtime_formated[f2a].equals("")) {
exportedtime_formated[f2a] = "01/JAN/04";
} else {
exportedtime_formated[f2a] = exportedtime_formated[f2a];
exportedtime_formated_ar.add(exportedtime_formated[f2a]);
}I'd be curious to know if it would be possible to rewrite your query using a JOIN so you could get all the data in one query. The way you've written it will require N network round trips, where N is the number of engine serial numbers. I wonder if clever application of a JOIN with a GROUP BY would do the trick in one?
I don't care for the formatting stuff you're doing, either. There's no need to ask the database for that. Bring the dates over and handle the formatting in Java using java.text.SimpleDateFormat. Less work for the database AND it won't be so tied to Oracle, since you won't need that TO_CHAR function anymore.
I'd give clients the raw java.sql.Date and let them worry about formatting it the way they wish. That's not a persistence concern.
I always prefer data structures like List and Map when I'm working with database result sets. They grow to fit the # of records that I get back. If I want arrays, I can always use the toArray() method to generate them. -
How can i get a array from a JSP ?
Hi all,
i have a STORED PROCEDURE like this:
static public void getMyArray(double [] xx) {
for (int i=0; i<myarr.length;i++){
myarr=3.145*i;
xx=myarr;
return ;
how can i get the array with XSQL and transform with a XSL ?
Is this at all possible?
Thanks for any help.
Achimu r asking how ca u get array from jsp?
and u r asking xsql ...some stuff i couldnot understand .can u repeat the question properly?
null -
How do I copy an array from a website to Excel using Firefox
Was running Firefox on Windows Vista. I could copy an array from finance.yahoo.com into an Excel spreadsheet by selecting the array with control key down then clicking on edit - copy selected cells, then pasting into an Excel sheet. I only had to tell it the upper left cell and the whole array went in properly
Now trying to do the same thing on a new machine running Windows 7, but the "copy selected cells" option is not available in the edit menu. Is there a way to copy an array with Firefox and Windows 7? These are big arrays. One cell at a time is out of the question.Try this Add-on --> https://addons.mozilla.org/en-US/firefox/addon/dafizilla-table2clipboard/
'''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
Not related to your question, but...
You may need to update some plug-ins. Check your plug-ins and update as necessary:
*Plug-in check --> http://www.mozilla.org/en-US/plugincheck/
*Adobe Shockwave for Director Netscape plug-in: [https://support.mozilla.org/en-US/kb/Using%20the%20Shockwave%20plugin%20with%20Firefox#w_installing-shockwave Installing ('''''or Updating''''') the Shockwave plugin with Firefox]
*'''''Adobe PDF Plug-In For Firefox and Netscape''''': [https://support.mozilla.org/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox]
*Shockwave Flash (Adobe Flash or Flash): [https://support.mozilla.org/en-US/kb/Managing%20the%20Flash%20plugin#w_updating-flash Updating Flash in Firefox]
*Next Generation Java Plug-in for Mozilla browsers: [https://support.mozilla.org/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java in Firefox] -
How to call a CString array from TestStand
I have a C++ DLL that uses a CString array, CString myString[ ], that I need to pass back to TestStand 4.0 for inclusion in my results database.
In the TestStand module definition the parameter argument Description comes up as a CStriing pointer (CString*) instead of a CStringArray.
When I put my array of strings into the Value Expression I get an error: Expected String, found Array of Strings.
I have no trouble passing just a string pointer but that's not working either.
Can someone help?
Thanks,
Steve SHi Steve,
I don't think that you can pass a CString Array from C++ DLL to TestStand 4.0 directly.
But you can do it another way: concatenate all Strings by a delimit in your CString Array to build a new String, then pass it to TestStand. In TestStand you can separate those Strings by the delimit, and rebuild a String Array.
For example:
// If this is your CString Array.
CString myString[] = {"AAA", "BBB", "CCC"};
// Build a new String in your C++, and pass it to TestStand.
char *myNewString = "AAA~BBB~CCC";
// Separate myNewString and build an Array in TestStand...
Hope that can help you!
Message Edited by My NI on 11-29-2007 11:34 AM
Regards
MY -
Passing an array from Java to Pl/SQL Procdures
I am relatively new to the Java world and I am unable to pass back an array from Java back to the calling PL/SQL procedure. I have read many of the posts that deal with this issue and in specificly have viewed Ask Tom. My main issue is trying to get the data types matched up. I am able to return varchar2, numbers, and the like, but an array of filenames is not happening. I have tried a variety of "types" but unable to accomplish the task. Please help.
I have my Java class basically defined as:
public static oracle.sql.ARRAY[] getCollection(String directory)
throws SQLException
{ // provide a directory and get a listing of files
File path = new File( directory );
String[] list = path.list();
return list;
SQL Type and PL/SQL Procedure is:
CREATE OR REPLACE TYPE PTO_FILE IS TABLE OF VARCHAR2(100);
create or replace function get_dir_collection( p_directory in varchar2 ) RETURN PTO_FILE
as language java
name 'DirCollection.getCollection( java.lang.String ) return oracle.sql.ARRAY[]';
/I know that it is not an ARRAY. It is however an "array" and I am attempting to map Java's String[][ to some "object" on the oracle side. I have looked at the link you sited and was not able to find the data mapping. I have found that mapping data types between different "languages" is some of the most difficult aspects of working with multiple languages.
Any suggestions? Thanks -
Reading in an array from a text file
I'm trying to use a text file to load in some configuratin
data (using actionscript 3) I have it working ok for simple stuff
like gamename=Chess&gamescore=100 , etc... but some of the data
needs to be in an array. Can someone please point me in the right
direction to how I can read in an array from a text file?
Thanks!the easiest way is to create a string with the (soon-to-be)
array elements separated by a delimiter (like a double comma). read
in your string, then use the split() method of strings to split
your string into an array. -
Can I move Array from one Xserve RAID to another and keep the data
I'd like to move a set of disk with an existing Array from one Xserve RAID to another. Can I simply shutdown both Xserve RAIDs and move the disk over, assuming I put the disk back in the same order?
Yes, you should be able to do this.
BE SURE YOU HAVE A BACKUP FIRST. -
Calling an array from another class
Ok I have this little program that I created to display values stored in an array. Well, I want my array to automatically be populated with the same values that are in another array that resides in a different class. Here is my code for the class that I want the values to be displayed:
import javax.swing.*;
import java.awt.*;
public class GUIRead extends JFrame
double[] interest = new double[3];
MemicCSVReader[] interestObjectArray = new MemicCSVReader[3];
interestObjectArray[0] = new MemicCSVReader();
interestObjectArray[1] = new MemicCSVReader();
interestObjectArray[2] = new MemicCSVReader():
for(int x = 0; x < 3; x++)
JPanel display = new JPanel();
JTextField interestText = new JTextField(10);
JPanel display2 = new JPanel();
JTextField interestText2 = new JTextField(10);
JPanel display3 = new JPanel();
JTextField interestText3 = new JTextField(10);
public GUIRead()
super("Test");
setSize(160,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
GridLayout config = new GridLayout(3,1);
FlowLayout config2 = new FlowLayout(FlowLayout.LEFT,10,10);
Container pane = getContentPane();
pane.setLayout(config2);
display.setLayout(config2);
display.add(interestText);
interestText.setText(interest[0]);
interestText.setEditable(false);
pane.add(display);
display2.setLayout(config2);
display2.add(interestText2);
interestText2.setText(interest[1]);
interestText2.setEditable(false);
pane.add(display2);
display3.setLayout(config2);
display3.add(interestText3);
interestText3.setText(interest[2]);
interestText3.setEditable(false);
pane.add(display3);
setContentPane(pane);
public static void main(String[] args)
GUIRead run = new GUIRead();
Here is my code that I want the double[] interest array to pull it's data from:
public class MemicCSVReader
double interestArray[];
MemicCSVReader()
String[] interestString = {"5.5","5.35","5.75"};
for(int x = 0; x < 3; x++)
interestArray[x] = Double.parseDouble(interestString[x]);
}Ok, thanks for your help. Now I have another problem. I can't get the values to display. Here is my code:
This is the program that runs the application:
import javax.swing.*;
import java.awt.*;
public class GUIRead extends JFrame
MemicCSVReader readCSV = new MemicCSVReader();
double[] interestDouble = readCSV.getInterestArray();
String[] interest;
JPanel display = new JPanel();
JTextField interestText = new JTextField(10);
JPanel display2 = new JPanel();
JTextField interestText2 = new JTextField(10);
JPanel display3 = new JPanel();
JTextField interestText3 = new JTextField(10);
public GUIRead()
super("Test");
setSize(160,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
GridLayout config = new GridLayout(3,1);
FlowLayout config2 = new FlowLayout(FlowLayout.LEFT,10,10);
Container pane = getContentPane();
pane.setLayout(config2);
display.setLayout(config2);
display.add(interestText);
interestText.setEditable(false);
pane.add(display);
display2.setLayout(config2);
display2.add(interestText2);
interestText2.setEditable(false);
pane.add(display2);
display3.setLayout(config2);
display3.add(interestText3);
interestText3.setEditable(false);
pane.add(display3);
setContentPane(pane);
public void actionPerformed()
for(int x = 0; x < 3; x++)
interest[x] = Double.toString(interestDouble[x]);
interestText.setText(interest[0]);
interestText2.setText(interest[1]);
interestText3.setText(interest[2]);
public static void main(String[] args)
GUIRead run = new GUIRead();
This is the file that it pulls the array from:
public class MemicCSVReader
private double[] InterestArray = new double[3];
MemicCSVReader()
double[] InterestArray = {5.5,5.35,5.75};
public double[] getInterestArray()
return InterestArray;
} -
[Solved] Move Software RAID 5 Array From NAS To Arch
Edit: I probably never had a problem at all, the error in dmesg probably just scared me, because after I disconnected it I noticed that /dev/d127 was 8.1 TB, the exact size of my RAID array node in my NAS which was /dev/md0, I just overlooked it. I reconnected it to my pc and mounted /dev/md127 to /mnt/raid and got this wonderful sight!
[bran@ra ~]$ ls /mnt/raid
data lost+found meta sys
[bran@ra ~]$ ls /mnt/raid/data/
data ftproot module _NAS_Media _NAS_Piczza_ _NAS_Recycle_RAID _P2P_DownLoad_ stackable _SYS_TMP TV USBHDD
download htdocs Movies _NAS_NFS_Exports_ NAS_Public nzbget-downloads PLEX_CONFIG sys tmp USBCopy
I bought a Thecus N4520 a few months ago and it's ok but programs crash a lot and they're hard to debug, apps have to be updated manually and the whole thing is moderately underpowered. I'm trying to move the software RAID 5 array from the NAS to my desktop, the kernel seems to detect that there is a RAID array but all these drives aren't part of it. I'm pretty new to RAID and I'm just getting my feet wet with it.
When I try to assemble the RAID array, it just tells me that it isn't an md array. How can I get it to build my array?
[bran@ra ~]$ sudo mdadm --assemble /dev/sdb /dev/sdc /dev/sdd /dev/sde
mdadm: device /dev/sdb exists but is not an md array.
Found this little chunk of info in dmesg, it says that the md devices have unknown partition tables.
[ 3.262225] md: raid1 personality registered for level 1
[ 3.262483] iTCO_wdt: Intel TCO WatchDog Timer Driver v1.10
[ 3.262508] iTCO_wdt: Found a Patsburg TCO device (Version=2, TCOBASE=0x0460)
[ 3.262585] iTCO_wdt: initialized. heartbeat=30 sec (nowayout=0)
[ 3.262933] md/raid1:md126: active with 4 out of 4 mirrors
[ 3.262961] md126: detected capacity change from 0 to 536850432
[ 3.263272] RAID1 conf printout:
[ 3.263274] --- wd:4 rd:4
[ 3.263276] disk 0, wo:0, o:1, dev:sdc3
[ 3.263276] disk 1, wo:0, o:1, dev:sdb3
[ 3.263277] disk 2, wo:0, o:1, dev:sdd3
[ 3.263278] disk 3, wo:0, o:1, dev:sde3
[ 3.263501] md: bind<sde4>
[ 3.264810] md: bind<sdb2>
[ 3.268262] async_tx: api initialized (async)
[ 3.272632] md: raid6 personality registered for level 6
[ 3.272636] md: raid5 personality registered for level 5
[ 3.272637] md: raid4 personality registered for level 4
[ 3.272905] md/raid:md127: device sdb2 operational as raid disk 1
[ 3.272908] md/raid:md127: device sde2 operational as raid disk 3
[ 3.272910] md/raid:md127: device sdd2 operational as raid disk 2
[ 3.272911] md/raid:md127: device sdc2 operational as raid disk 0
[ 3.273211] md/raid:md127: allocated 0kB
[ 3.273241] md/raid:md127: raid level 5 active with 4 out of 4 devices, algorithm 2
[ 3.273243] RAID conf printout:
[ 3.273244] --- level:5 rd:4 wd:4
[ 3.273245] disk 0, o:1, dev:sdc2
[ 3.273246] disk 1, o:1, dev:sdb2
[ 3.273247] disk 2, o:1, dev:sdd2
[ 3.273248] disk 3, o:1, dev:sde2
[ 3.273273] md127: detected capacity change from 0 to 8929230716928
[ 3.273322] RAID conf printout:
[ 3.273326] --- level:5 rd:4 wd:4
[ 3.273329] disk 0, o:1, dev:sdc2
[ 3.273331] disk 1, o:1, dev:sdb2
[ 3.273332] disk 2, o:1, dev:sdd2
[ 3.273360] disk 3, o:1, dev:sde2
[ 3.283617] md126: unknown partition table
[ 3.309239] md127: unknown partition table
[ 3.312660] md: bind<sdb4>
[ 3.318291] md/raid1:md124: not clean -- starting background reconstruction
[ 3.318296] md/raid1:md124: active with 4 out of 4 mirrors
[ 3.318333] md124: detected capacity change from 0 to 10736291840
[ 3.318385] RAID1 conf printout:
[ 3.318391] --- wd:4 rd:4
[ 3.318395] disk 0, wo:0, o:1, dev:sdc4
[ 3.318398] disk 1, wo:0, o:1, dev:sdb4
[ 3.318402] disk 2, wo:0, o:1, dev:sdd4
[ 3.318405] disk 3, wo:0, o:1, dev:sde4
[ 3.319890] md124: unknown partition table
[ 3.323462] md: bind<sde1>
[ 3.338094] md/raid1:md125: active with 4 out of 4 mirrors
[ 3.338225] md125: detected capacity change from 0 to 2146414592
[ 3.338253] RAID1 conf printout:
[ 3.338258] --- wd:4 rd:4
[ 3.338262] disk 0, wo:0, o:1, dev:sdc1
[ 3.338266] disk 1, wo:0, o:1, dev:sdb1
[ 3.338268] disk 2, wo:0, o:1, dev:sdd1
[ 3.338271] disk 3, wo:0, o:1, dev:sde1
Here's my full dmesg
mdadm.conf
# The designation "partitions" will scan all partitions found in /proc/partitions
DEVICE partitions
ARRAY /dev/md127 metadata=1.2 name=(none):0 UUID=d1d14afc:23490940:a0f7f996:d7b87dfb
ARRAY /dev/md126 metadata=1.2 name=(none):50 UUID=d43d5dd6:9446766e:1a7486f4:b811e16d
ARRAY /dev/md125 metadata=1.2 name=(none):10 UUID=f502437a:d27d335a:d11578d5:6e119d58
ARRAY /dev/md124 metadata=1.2 name=(none):70 UUID=ea980643:5c1b79e8:64f1b4cb:2462799b
Last edited by brando56894 (2014-04-21 22:51:01)Sorry I numbered them to show the flow of information, this was also just a place for me to store info as I worked through it. I managed to get it to work by creating a partition that takes up the whole drive and is actually 22 GB larger than all the other drives (since I found out that the had root, swap and home partitions that are no longer needed).
I should be able to resize the other partitions without a problem, correct? They're EXT4. Should I unmount the raid array and do them individually, remount the array, let it sync and do the next? Or just unmount the array, resize all of them, mount it and let it sync? -
I can not get the right frequency out of my NI-DAQ 6062E card from Matlab
Hi.
My name is Johan and I want to generate an analog square waveform with 5.76 kb/s in frequency with my NI DAQCard-6062E from Matlab.
When I run in Matlab the program below, I get the frequency of 5.747 kb/s on the output channel (even thou I have chosen 5.76 kb/s). When I try to change the sample rate, to higher values in Matlab, I get the same frequency until I choose the sample rate to 5.79 kb/s. The output signal is in that case is 5.813 kb/s.
So my problem is that I can't get the exact frequency of 5.76 kb/s.
How do I solve this.
Thankful for help.
Best regards, Johan
Program in Matlab:
clear all
openDAQ=daqfind; %Detect any open DAQ channels
for i=1:length(openDAQ), %Close any open DAQ channels
stop(openDAQ(i));
end
ao = analogoutput('nidaq',1); %Create an object for analog output
addchannel(ao, [0 1]);
set(ao, 'SampleRate', 2*5760); %Here the sample rate is specied. 2*, because to get right samplerate
y=[80,-80] %Sets theoutput values to 80 and -80 (As -1 and 1)
putdata(ao, [y' y']); %Sends the values to out buffer
set(ao,'RepeatOutput',inf) %Repeats sending in infinity
set(ao, 'TriggerType', 'Immediate'); %Choose trigger to immediate, because sending values shall occur driect after start command.
start(ao);
%stop(ao)Hello Johan!
Bad news I am afraid….
I assume you are using the Data Acquisition Toolbox from the Mathworks and when it comes to support on that interface I have to advice you to contact the Mathworks for assistance. We don't provide any support on their data acquisition interface since we have nothing to do with it.
Sorry for the inconvenience this might cause you.
Regards,
Jimmie A.
Applications Engineer, National Instruments
Regards,
Jimmie Adolph
Systems Engineer Manager, National Instruments Northern Region
Bring Me The Horizon - Sempiternal -
Code for how to read an integer array from the command prompt...
hello,
Could anyone give me the code for how to read an integer array from the command prompt...its very urgent!..If you are using a recent version of Java (5 or later) you can use Scanner:
http://java.sun.com/javase/6/docs/api/java/util/Scanner.html
That page has some example code on it, too. -
I also posted this on the "Fieldpoint Family" board.
Is it possible to send a 2D text array from my LV program running on my PC to a LV program running in Realtime on my FP2010 Processor?
When I tried to build the RT program using the wizard, it didn't find the array and add it to the "Indicator List:". When I changed the array to a control, it didn't show up in the "Control List:" I tried it with TCP/IP, UDP, DataSocket, and Logos.
If it's possible, then how is it done?
Using LV7.0 Pro on Win2K
Thanks,
MikeThe Fieldpoint Family seems to be taking care of this one:
http://forums.ni.com/ni/board/message?board.id=110&message.id=3104
Andy F.
Applications Engineer
National Instruments
National Instruments
Maybe you are looking for
-
I have a macbook pro 13 " and I shall like settling on an external hard disk ( SSD) Windows 7 not to split up the main disk.
-
Internet Explorer 11 slow response on Windows 7 x64 virtual machine
I have a number of virtual machines running Windows 7 64bit on my network. They are set up on a server running VMWare ESXi 5.1.0. Their users access them from Windows 7 desktops via Remote Desktop. The overall performance of the Virtual Machines is f
-
Cannot file, save as in Adobe Reader 9.1.2
I currently access my electricity and gas bill online and both of these are always displayed in pdf format. Unfortunately, since updating to reader 9.1.2, I am no longer able to see the toolbar menu, normally above the picture icon toolbar menu, so
-
new iMac, old external hard drive - where do I plug it in?
-
Smartforms : print standard texts or texts out of document with command in.
We used to have an output via Sapscript (printout of a purchase order) and the output was containing standard texts or text out of the purchase order, which contains commands (a test in the standard text or an include of another standard text). This